This repository contains a Python script that interacts with OpenAI's API to create and manage an AI assistant. The assistant is designed to respond in a specific style and help with questions related to a provided document. The script includes functionalities for managing files, vector stores, and threads to facilitate interactions with the AI assistant.
- Python 3.12
- Python libraries:
dotenv
library for environment variable managementopenai
library for interacting with OpenAI's API
-
Clone the repository:
git clone https://github.com/burakai/mooze.git cd mooze
-
Install required packages:
pip install -r requirements.txt
-
.env
file in the root directory of your project will be created automatically by the script in the new version:... OPENAI_API_KEY="your-openai-api-key" ...
-
Initialize the Assistant:
- The script starts by loading environment variables and setting up the OpenAI client.
- It configures the assistant with predefined instructions and attempts to retrieve an existing assistant using
assistant_id
. If not found, it prompts to create a new assistant.
-
Manage Threads:
- The script tries to retrieve an existing thread using
thread_id
. If not found, it prompts to create a new thread.
- The script tries to retrieve an existing thread using
-
Manage Vector Stores:
- The script attempts to retrieve an existing vector store using
vector_store_id
. If not found, the script exits.
- The script attempts to retrieve an existing vector store using
-
File Handling:
- The script lists existing files and provides options to upload new files, continue with existing files, or start with no files.
- Uploaded files are listed and used to create a vector store file.
-
Interaction:
- The script provides a continuous prompt for user input to interact with the assistant.
- User inputs are sent to the assistant, and responses are retrieved and displayed.
To run the script, execute the following command in your terminal:
python main.py