# AI Assistant Manager
![AI Assistant Manager Banner](ai-assistant-manager.png)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ai-assistant-manager)
![PyPI version](https://img.shields.io/pypi/v/ai-assistant-manager)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
![Build Status](https://img.shields.io/github/actions/workflow/status/DEV3L/ai-assistant-manager/continuous-integration.yml?branch=main)
![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)
## Introduction
**AI Assistant Manager** is an **open-source** tool designed to simplify the management of OpenAI Assistants. It provides a suite of tools and services for creating, listing, and deleting assistants, as well as handling vector stores and retrieval files. The project includes both end-to-end and unit tests, leveraging the Hatch build system for environment management and testing.
## Value Proposition
By automating the management of AI assistants and their associated resources, **AI Assistant Manager** streamlines workflows for developers working with OpenAI's API. It reduces the complexity involved in assistant lifecycle management, vector store handling, and file operations, allowing developers to focus on building intelligent applications without getting bogged down in infrastructure details.
## Key Features
- **Assistant Management**: Create, list, and delete OpenAI assistants with ease.
- **Vector Store Handling**: Manage vector stores for retrieval-augmented generation (RAG) models.
- **Retrieval File Management**: Create and handle retrieval files efficiently.
- **Open Source**: Freely available for modification and integration.
- **Testing Suite**: Includes end-to-end and unit tests to ensure reliability.
- **Environment Management**: Utilizes Hatch for consistent development environments.
- **Logging**: Integrated logging using Loguru for better traceability.
## Technology Stack
- **Programming Language**: Python 3.11+
- **Frameworks and Libraries**:
- **OpenAI API**: Interact with OpenAI's GPT models.
- **Loguru**: Advanced logging capabilities.
- **Python-dotenv**: Manage environment variables.
- **Python-dateutil**: For date parsing.
- **Hatch**: Environment management and packaging.
- **Pytest**: Testing framework.
- **Twine**: For publishing packages to PyPI.
## Installation Instructions
### Install via PyPI
**AI Assistant Manager** is available on PyPI and can be installed using `pip`:
```bash
pip install ai-assistant-manager
```
For more details, visit the [PyPI project page](https://pypi.org/project/ai-assistant-manager/).
### From Source
1. **Clone the repository**:
```bash
git clone https://github.com/DEV3L/ai-assistant-manager
cd ai-assistant-manager
```
2. **Set up environment variables**:
Copy the `env.local` file to `.env` and replace placeholders with your actual OpenAI API key:
```bash
cp env.local .env
```
Edit `.env` to add your `OPENAI_API_KEY`:
```dotenv
OPENAI_API_KEY=your_openai_api_key
```
3. **Set up a virtual environment**:
**Install Hatch** (if not already installed):
```bash
pip install hatch
```
**Create and activate the virtual environment**:
```bash
hatch env create
hatch shell
```
## Usage Guide
### Environment Variables
Configure the following environment variables in your `.env` file:
- `OPENAI_API_KEY`: Your OpenAI API key.
- `OPENAI_MODEL`: The model to use (default: `gpt-4o-2024-08-06`).
- `ASSISTANT_DESCRIPTION`: Description of the assistant (default: `AI Assistant Manager`).
- `ASSISTANT_NAME`: Name of the assistant (default: `AI Assistant Manager`).
- `BIN_DIR`: Directory for binaries (default: `bin`).
- `DATA_DIR`: Directory for data files (default: `data`).
- `DATA_FILE_PREFIX`: Prefix for data files (default: `AI Assistant Manager`).
### Running the Example
To see **AI Assistant Manager** in action, you can run the provided example script:
```python
from loguru import logger
from ai_assistant_manager.assistants.assistant_service import AssistantService
from ai_assistant_manager.chats.chat import Chat
from ai_assistant_manager.clients.openai_api import OpenAIClient, build_openai_client
from ai_assistant_manager.env_variables import set_env_variables
from ai_assistant_manager.exporters.directory.directory_exporter import DirectoryExporter
from ai_assistant_manager.exporters.files.files_exporter import FilesExporter
from ai_assistant_manager.prompts.prompt import get_prompt
def main():
DirectoryExporter("directory").export()
FilesExporter("about.txt").export()
assistant_name = "AI-Assistant-Manager-Test"
logger.info(f"Building {assistant_name}")
client = OpenAIClient(build_openai_client())
service = AssistantService(client, get_prompt())
logger.info("Removing existing assistant and category files")
service.delete_assistant()
assistant_id = service.get_assistant_id()
logger.info(f"Assistant ID: {assistant_id}")
chat = Chat(client, assistant_id)
chat.start()
message = "What is the AI Assistant Manager?"
print(f"\nMessage:\n{message}")
chat_response = chat.send_user_message(message)
print(f"\n{service.assistant_name}:\n{chat_response.message}")
print(f"\nTokens: {chat_response.token_count}")
service.delete_assistant()
if __name__ == "__main__":
try:
set_env_variables()
main()
except Exception as e:
logger.info(f"Error: {e}")
```
### Running the Script
```bash
python run_end_to_end.py
```
This script will:
- Export data from specified directories.
- Create an assistant service.
- Start a chat session with the assistant.
- Send a message and display the assistant's response.
- Clean up by deleting the assistant after the session.
## Available Scripts
- **Run End-to-End Test**:
```bash
hatch run e2e
```
- **Run Unit Tests**:
```bash
hatch run test
```
- **Publish Package to PyPI**:
```bash
hatch run publish
```
_Note: These scripts are defined in `pyproject.toml` under `[tool.hatch.envs.default.scripts]`._
## Testing Instructions
### End-to-End Test
Run the end-to-end test to ensure the tool works as expected:
```bash
hatch run e2e
```
### Unit Tests
To run unit tests:
```bash
hatch run test
```
Coverage reports are generated using `pytest-cov`.
### Coverage Gutters
To monitor code coverage in VSCode:
1. Install the **Coverage Gutters** extension.
2. Run:
```bash
Command + Shift + P => Coverage Gutters: Watch
```
## Project Structure Overview
```
ai-assistant-manager/
├── ai_assistant_manager/
│ ├── assistants/
│ │ └── assistant_service.py
│ ├── chats/
│ │ ├── chat.py
│ │ └── chat_response.py
│ ├── clients/
│ │ └── openai_api.py
│ ├── exporters/
│ │ ├── directory/
│ │ │ └── directory_exporter.py
│ │ ├── files/
│ │ │ └── files_exporter.py
│ │ └── exporter.py
│ ├── prompts/
│ │ ├── sample_prompt.md
│ │ └── prompt.py
│ ├── content_data.py
│ ├── env_variables.py
│ └── encoding.py
├── tests/
│ ├── assistants/
│ │ └── assistant_service_test.py
│ ├── chats/
│ │ ├── chat_test.py
│ │ └── chat_response_test.py
│ ├── clients/
│ │ └── openai_api_test.py
│ ├── exporters/
│ │ ├── directory/
│ │ │ └── directory_exporter_test.py
│ │ ├── files/
│ │ │ └── files_exporter_test.py
│ │ └── exporter_test.py
│ ├── prompts/
│ │ └── prompt_test.py
│ ├── env_variables_test.py
│ └── timer_test.py
├── .env.default
├── pyproject.toml
├── README.md
├── run_end_to_end.py
├── LICENSE
```
- **ai_assistant_manager/**: Main package containing the code.
- **assistants/**: Assistant management services.
- **chats/**: Chat functionalities.
- **clients/**: OpenAI client interactions.
- **exporters/**: Export data to files or directories.
- **prompts/**: Manage assistant prompts.
- **env_variables.py**: Environment variable management.
- **encoding.py**: Encoding configurations.
- **tests/**: Contains unit tests for the code.
- **.env.default**: Template for environment variables.
- **pyproject.toml**: Project configuration and dependencies.
- **run_end_to_end.py**: Script to execute the end-to-end process.
- **LICENSE**: Project license information.
## Contributing Guidelines
We welcome contributions! Please follow these steps:
1. **Fork the repository** on GitHub.
2. **Create a new branch** for your feature or bugfix:
```bash
git checkout -b feature/your-feature-name
```
3. **Make your changes** and commit them with clear messages.
4. **Run tests** to ensure nothing is broken:
```bash
hatch run test
```
5. **Push to your fork** and submit a **pull request** to the `main` branch.
## Code of Conduct
By participating in this project, you agree to abide by the following guidelines:
- **Be respectful and considerate** of others.
- **Avoid discriminatory or offensive language**.
- **Report any unacceptable behavior** to the project maintainers.
## License Information
This project is licensed under the **MIT License**. See the [LICENSE](LICENSE) file for details.
## Acknowledgments
- **OpenAI** - For providing the GPT models used in assistant management.
- **Community Contributors** - Thank you to all who have contributed through issues and pull requests.
## Additional Resources
- **PyPI Project Page**: [ai-assistant-manager](https://pypi.org/project/ai-assistant-manager/)
Raw data
{
"_id": null,
"home_page": null,
"name": "ai-assistant-manager",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": "AI, API, NLP, artificial intelligence, assistant, automation, chatbot, data science, deep learning, machine learning, management, natural language processing, openai, python, vector store",
"author": null,
"author_email": "Justin Beall <jus.beall@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/8e/68/a664b8b4957001236e9c2f0be39af0350f691e26bfd378b16bfff9eb5493/ai_assistant_manager-2.2.0.tar.gz",
"platform": null,
"description": "# AI Assistant Manager\n\n![AI Assistant Manager Banner](ai-assistant-manager.png)\n\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ai-assistant-manager)\n![PyPI version](https://img.shields.io/pypi/v/ai-assistant-manager)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n![Build Status](https://img.shields.io/github/actions/workflow/status/DEV3L/ai-assistant-manager/continuous-integration.yml?branch=main)\n![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)\n\n## Introduction\n\n**AI Assistant Manager** is an **open-source** tool designed to simplify the management of OpenAI Assistants. It provides a suite of tools and services for creating, listing, and deleting assistants, as well as handling vector stores and retrieval files. The project includes both end-to-end and unit tests, leveraging the Hatch build system for environment management and testing.\n\n## Value Proposition\n\nBy automating the management of AI assistants and their associated resources, **AI Assistant Manager** streamlines workflows for developers working with OpenAI's API. It reduces the complexity involved in assistant lifecycle management, vector store handling, and file operations, allowing developers to focus on building intelligent applications without getting bogged down in infrastructure details.\n\n## Key Features\n\n- **Assistant Management**: Create, list, and delete OpenAI assistants with ease.\n- **Vector Store Handling**: Manage vector stores for retrieval-augmented generation (RAG) models.\n- **Retrieval File Management**: Create and handle retrieval files efficiently.\n- **Open Source**: Freely available for modification and integration.\n- **Testing Suite**: Includes end-to-end and unit tests to ensure reliability.\n- **Environment Management**: Utilizes Hatch for consistent development environments.\n- **Logging**: Integrated logging using Loguru for better traceability.\n\n## Technology Stack\n\n- **Programming Language**: Python 3.11+\n- **Frameworks and Libraries**:\n - **OpenAI API**: Interact with OpenAI's GPT models.\n - **Loguru**: Advanced logging capabilities.\n - **Python-dotenv**: Manage environment variables.\n - **Python-dateutil**: For date parsing.\n - **Hatch**: Environment management and packaging.\n - **Pytest**: Testing framework.\n - **Twine**: For publishing packages to PyPI.\n\n## Installation Instructions\n\n### Install via PyPI\n\n**AI Assistant Manager** is available on PyPI and can be installed using `pip`:\n\n```bash\npip install ai-assistant-manager\n```\n\nFor more details, visit the [PyPI project page](https://pypi.org/project/ai-assistant-manager/).\n\n### From Source\n\n1. **Clone the repository**:\n\n ```bash\n git clone https://github.com/DEV3L/ai-assistant-manager\n cd ai-assistant-manager\n ```\n\n2. **Set up environment variables**:\n\n Copy the `env.local` file to `.env` and replace placeholders with your actual OpenAI API key:\n\n ```bash\n cp env.local .env\n ```\n\n Edit `.env` to add your `OPENAI_API_KEY`:\n\n ```dotenv\n OPENAI_API_KEY=your_openai_api_key\n ```\n\n3. **Set up a virtual environment**:\n\n **Install Hatch** (if not already installed):\n\n ```bash\n pip install hatch\n ```\n\n **Create and activate the virtual environment**:\n\n ```bash\n hatch env create\n hatch shell\n ```\n\n## Usage Guide\n\n### Environment Variables\n\nConfigure the following environment variables in your `.env` file:\n\n- `OPENAI_API_KEY`: Your OpenAI API key.\n- `OPENAI_MODEL`: The model to use (default: `gpt-4o-2024-08-06`).\n- `ASSISTANT_DESCRIPTION`: Description of the assistant (default: `AI Assistant Manager`).\n- `ASSISTANT_NAME`: Name of the assistant (default: `AI Assistant Manager`).\n- `BIN_DIR`: Directory for binaries (default: `bin`).\n- `DATA_DIR`: Directory for data files (default: `data`).\n- `DATA_FILE_PREFIX`: Prefix for data files (default: `AI Assistant Manager`).\n\n### Running the Example\n\nTo see **AI Assistant Manager** in action, you can run the provided example script:\n\n```python\nfrom loguru import logger\n\nfrom ai_assistant_manager.assistants.assistant_service import AssistantService\nfrom ai_assistant_manager.chats.chat import Chat\nfrom ai_assistant_manager.clients.openai_api import OpenAIClient, build_openai_client\nfrom ai_assistant_manager.env_variables import set_env_variables\nfrom ai_assistant_manager.exporters.directory.directory_exporter import DirectoryExporter\nfrom ai_assistant_manager.exporters.files.files_exporter import FilesExporter\nfrom ai_assistant_manager.prompts.prompt import get_prompt\n\ndef main():\n DirectoryExporter(\"directory\").export()\n FilesExporter(\"about.txt\").export()\n\n assistant_name = \"AI-Assistant-Manager-Test\"\n logger.info(f\"Building {assistant_name}\")\n\n client = OpenAIClient(build_openai_client())\n service = AssistantService(client, get_prompt())\n\n logger.info(\"Removing existing assistant and category files\")\n service.delete_assistant()\n\n assistant_id = service.get_assistant_id()\n logger.info(f\"Assistant ID: {assistant_id}\")\n\n chat = Chat(client, assistant_id)\n chat.start()\n\n message = \"What is the AI Assistant Manager?\"\n print(f\"\\nMessage:\\n{message}\")\n\n chat_response = chat.send_user_message(message)\n print(f\"\\n{service.assistant_name}:\\n{chat_response.message}\")\n print(f\"\\nTokens: {chat_response.token_count}\")\n\n service.delete_assistant()\n\nif __name__ == \"__main__\":\n try:\n set_env_variables()\n main()\n except Exception as e:\n logger.info(f\"Error: {e}\")\n```\n\n### Running the Script\n\n```bash\npython run_end_to_end.py\n```\n\nThis script will:\n\n- Export data from specified directories.\n- Create an assistant service.\n- Start a chat session with the assistant.\n- Send a message and display the assistant's response.\n- Clean up by deleting the assistant after the session.\n\n## Available Scripts\n\n- **Run End-to-End Test**:\n\n ```bash\n hatch run e2e\n ```\n\n- **Run Unit Tests**:\n\n ```bash\n hatch run test\n ```\n\n- **Publish Package to PyPI**:\n\n ```bash\n hatch run publish\n ```\n\n_Note: These scripts are defined in `pyproject.toml` under `[tool.hatch.envs.default.scripts]`._\n\n## Testing Instructions\n\n### End-to-End Test\n\nRun the end-to-end test to ensure the tool works as expected:\n\n```bash\nhatch run e2e\n```\n\n### Unit Tests\n\nTo run unit tests:\n\n```bash\nhatch run test\n```\n\nCoverage reports are generated using `pytest-cov`.\n\n### Coverage Gutters\n\nTo monitor code coverage in VSCode:\n\n1. Install the **Coverage Gutters** extension.\n2. Run:\n\n ```bash\n Command + Shift + P => Coverage Gutters: Watch\n ```\n\n## Project Structure Overview\n\n```\nai-assistant-manager/\n\u251c\u2500\u2500 ai_assistant_manager/\n\u2502 \u251c\u2500\u2500 assistants/\n\u2502 \u2502 \u2514\u2500\u2500 assistant_service.py\n\u2502 \u251c\u2500\u2500 chats/\n\u2502 \u2502 \u251c\u2500\u2500 chat.py\n\u2502 \u2502 \u2514\u2500\u2500 chat_response.py\n\u2502 \u251c\u2500\u2500 clients/\n\u2502 \u2502 \u2514\u2500\u2500 openai_api.py\n\u2502 \u251c\u2500\u2500 exporters/\n\u2502 \u2502 \u251c\u2500\u2500 directory/\n\u2502 \u2502 \u2502 \u2514\u2500\u2500 directory_exporter.py\n\u2502 \u2502 \u251c\u2500\u2500 files/\n\u2502 \u2502 \u2502 \u2514\u2500\u2500 files_exporter.py\n\u2502 \u2502 \u2514\u2500\u2500 exporter.py\n\u2502 \u251c\u2500\u2500 prompts/\n\u2502 \u2502 \u251c\u2500\u2500 sample_prompt.md\n\u2502 \u2502 \u2514\u2500\u2500 prompt.py\n\u2502 \u251c\u2500\u2500 content_data.py\n\u2502 \u251c\u2500\u2500 env_variables.py\n\u2502 \u2514\u2500\u2500 encoding.py\n\u251c\u2500\u2500 tests/\n\u2502 \u251c\u2500\u2500 assistants/\n\u2502 \u2502 \u2514\u2500\u2500 assistant_service_test.py\n\u2502 \u251c\u2500\u2500 chats/\n\u2502 \u2502 \u251c\u2500\u2500 chat_test.py\n\u2502 \u2502 \u2514\u2500\u2500 chat_response_test.py\n\u2502 \u251c\u2500\u2500 clients/\n\u2502 \u2502 \u2514\u2500\u2500 openai_api_test.py\n\u2502 \u251c\u2500\u2500 exporters/\n\u2502 \u2502 \u251c\u2500\u2500 directory/\n\u2502 \u2502 \u2502 \u2514\u2500\u2500 directory_exporter_test.py\n\u2502 \u2502 \u251c\u2500\u2500 files/\n\u2502 \u2502 \u2502 \u2514\u2500\u2500 files_exporter_test.py\n\u2502 \u2502 \u2514\u2500\u2500 exporter_test.py\n\u2502 \u251c\u2500\u2500 prompts/\n\u2502 \u2502 \u2514\u2500\u2500 prompt_test.py\n\u2502 \u251c\u2500\u2500 env_variables_test.py\n\u2502 \u2514\u2500\u2500 timer_test.py\n\u251c\u2500\u2500 .env.default\n\u251c\u2500\u2500 pyproject.toml\n\u251c\u2500\u2500 README.md\n\u251c\u2500\u2500 run_end_to_end.py\n\u251c\u2500\u2500 LICENSE\n```\n\n- **ai_assistant_manager/**: Main package containing the code.\n - **assistants/**: Assistant management services.\n - **chats/**: Chat functionalities.\n - **clients/**: OpenAI client interactions.\n - **exporters/**: Export data to files or directories.\n - **prompts/**: Manage assistant prompts.\n - **env_variables.py**: Environment variable management.\n - **encoding.py**: Encoding configurations.\n- **tests/**: Contains unit tests for the code.\n- **.env.default**: Template for environment variables.\n- **pyproject.toml**: Project configuration and dependencies.\n- **run_end_to_end.py**: Script to execute the end-to-end process.\n- **LICENSE**: Project license information.\n\n## Contributing Guidelines\n\nWe welcome contributions! Please follow these steps:\n\n1. **Fork the repository** on GitHub.\n2. **Create a new branch** for your feature or bugfix:\n\n ```bash\n git checkout -b feature/your-feature-name\n ```\n\n3. **Make your changes** and commit them with clear messages.\n4. **Run tests** to ensure nothing is broken:\n\n ```bash\n hatch run test\n ```\n\n5. **Push to your fork** and submit a **pull request** to the `main` branch.\n\n## Code of Conduct\n\nBy participating in this project, you agree to abide by the following guidelines:\n\n- **Be respectful and considerate** of others.\n- **Avoid discriminatory or offensive language**.\n- **Report any unacceptable behavior** to the project maintainers.\n\n## License Information\n\nThis project is licensed under the **MIT License**. See the [LICENSE](LICENSE) file for details.\n\n## Acknowledgments\n\n- **OpenAI** - For providing the GPT models used in assistant management.\n- **Community Contributors** - Thank you to all who have contributed through issues and pull requests.\n\n## Additional Resources\n\n- **PyPI Project Page**: [ai-assistant-manager](https://pypi.org/project/ai-assistant-manager/)\n",
"bugtrack_url": null,
"license": "/* * ---------------------------------------------------------------------------- * \"THE BEER-WARE LICENSE\" (Revision 42): * <jus.beall@gmail.com> wrote this file. As long as you retain this notice you * can do whatever you want with this stuff. If we meet some day, and you think * this stuff is worth it, you can buy me a beer in return. Justin Lee Beall * ---------------------------------------------------------------------------- */",
"summary": "This repository provides tools and services to manage OpenAI Assistants, including creating, listing, and deleting assistants, as well as handling vector stores and retrieval files.",
"version": "2.2.0",
"project_urls": {
"repository": "https://github.com/DEV3L/open-ai-assistant"
},
"split_keywords": [
"ai",
" api",
" nlp",
" artificial intelligence",
" assistant",
" automation",
" chatbot",
" data science",
" deep learning",
" machine learning",
" management",
" natural language processing",
" openai",
" python",
" vector store"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "744ee7e80379f8f0be806f6aa97994473edbbfd93473c795d568f3f26fba20f9",
"md5": "26696e7be642f5af84c504424d1e30f1",
"sha256": "56a7cebd31e3c720cb4b2f71d1a0df40bb5f26095cd889751dc8cfb302173832"
},
"downloads": -1,
"filename": "ai_assistant_manager-2.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "26696e7be642f5af84c504424d1e30f1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 26524,
"upload_time": "2024-11-06T01:46:26",
"upload_time_iso_8601": "2024-11-06T01:46:26.062447Z",
"url": "https://files.pythonhosted.org/packages/74/4e/e7e80379f8f0be806f6aa97994473edbbfd93473c795d568f3f26fba20f9/ai_assistant_manager-2.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8e68a664b8b4957001236e9c2f0be39af0350f691e26bfd378b16bfff9eb5493",
"md5": "f0b5c219e5d0c8bbabae3078c569b203",
"sha256": "0c5e9e84c696679afab26e108acb862cc207ba95fd7312c1866f697a6f8fb4fe"
},
"downloads": -1,
"filename": "ai_assistant_manager-2.2.0.tar.gz",
"has_sig": false,
"md5_digest": "f0b5c219e5d0c8bbabae3078c569b203",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 17023,
"upload_time": "2024-11-06T01:46:27",
"upload_time_iso_8601": "2024-11-06T01:46:27.159246Z",
"url": "https://files.pythonhosted.org/packages/8e/68/a664b8b4957001236e9c2f0be39af0350f691e26bfd378b16bfff9eb5493/ai_assistant_manager-2.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-06 01:46:27",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "DEV3L",
"github_project": "open-ai-assistant",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"lcname": "ai-assistant-manager"
}