From 4f5f678aab65ed652f20e6d7ae91d5ed7c6f7952 Mon Sep 17 00:00:00 2001 From: Charles Calapini Date: Sun, 3 Dec 2023 07:49:18 -0700 Subject: [PATCH] Added Docs --- README.md | 23 +++++++++++++++++++++++ frontend/app.py | 15 ++++++--------- 2 files changed, 29 insertions(+), 9 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..9a5078e --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# AI Assistant Application + +This application is a Streamlit interface for interacting with OpenAI's AI assistants. It allows users to create assistants, upload files to them, send them messages, and view their responses. + +Here's a high-level overview of what each function does: + +- `init()`: Initializes session state variables. +- `set_apikey()`: Allows the user to input their OpenAI API key. +- `config(client)`: Fetches a list of assistants and returns the selected assistant's ID. +- `upload_file(client, assistant_id, uploaded_file)`: Uploads a file to the selected assistant. +- `assistant_handler(client, assistant_id)`: Handles assistant updates, including name, instructions, model, and file management. +- `create_assistant(client)`: Creates a new assistant with a given name, instructions, and model. +- `chat_prompt(client, assistant_option)`: Handles the chat interface, allowing the user to send messages to the assistant and receive responses. +- `chat_display(client)`: Displays the chat history, including any images returned by the assistant. +- `main()`: The main function that runs the Streamlit application. It handles API key input, assistant selection, and chat initiation. + +## Installation + +1. Clone the repository: `git clone https://github.com/calapsss/assistants-api-easy.git` +2. Navigate to `assistants-api-easy` directory: `cd assistants-api-easy` +3. You can install the package `poetry install` +4. Navigate to frontend folder: `cd frontend` +5. Run with Poetry: `poetry run streamlit run app.py` diff --git a/frontend/app.py b/frontend/app.py index b1ef88e..7377d59 100644 --- a/frontend/app.py +++ b/frontend/app.py @@ -25,8 +25,6 @@ def init(): if "thread_id" not in st.session_state: st.session_state.thread_id = None - - def set_apikey(): st.sidebar.header('Configure') api_key = st.sidebar.text_input("Enter your OpenAI API key", type="password") @@ -188,18 +186,17 @@ def chat_prompt(client, assistant_option): st.empty() chat_display(client) - - def chat_display(client): st.session_state.messages = client.beta.threads.messages.list( thread_id=st.session_state.thread_id ).data - x = 0 - for message in st.session_state.messages: - print(x) - print(message) - x += 1 + #Used this for debugging + # x = 0 + # for message in st.session_state.messages: + # print(x) + # print(message) + # x += 1 for message in reversed(st.session_state.messages): if message.role in ["user", "assistant"]: