๐ฌ OpenAI Assistants API chat UI ๐ ๏ธ It works easily by setting the ASSISTANT ID ๐ Supports file upload and file download ๐ Supports Streaming API ๐ช Support to Azure OpenAI
gpt-assistants-api-ui
- ๐ฌ OpenAI Assistants API chat UI
- ๐ ๏ธ It works quickly by setting the ASSISTANT IDs
- ๐ Supports file upload and file download
- ๐ Supports Streaming API
- ๐ฅ Supports multiple Assistant profiles in one place
- ๐ช Support to Azure OpenAI
๐ Quick Start
- ๐ค Create an assistant on the OpenAI site & Get assistant ID (https://platform.openai.com/assistants)
- ๐ Get the API key from OpenAI (https://platform.openai.com/api-keys)
- โฌ๏ธ Clone the repository
$ git clone https://github.com/ryo-ma/gpt-assistants-api-ui.git
- ๐ฆ Install dependencies
$ poetry install
- โ๏ธ Set environment variables file
.env
# OpenAI settings
OPENAIAPIKEY="sk-xxx"
# When using only one assistant, set the following, unset the OPENAI_ASSISTANTS variable. ASSISTANTID="asstxxx" ASSISTANT_TITLE="Assistants API UI" # This is for the single agent title
# When using multiple assistants, set the following. OPENAIASSISTANTS='[{"id": "asstxxx", "title": "Assistants XXX UI"}, {"id": "asst_yyy", "title": "Assistants YYY UI"}]' # App settings ENABLEDFILEUPLOAD_MESSAGE="Upload a file" # Leave empty to disable AUTHENTICATI # Must change to True if you require authentication
If you use azure instead, set AZUREOPENAIENDPOINT and AZUREOPENAIKEY
- ๐ Set Authentication configuration (optional)
.streamlit/secrets.toml as below:
[credentials]
usernames = { jsmith = {failedloginattempts = 0, loggedin = false, name = "John Smith", password = "abc"}, rbriggs = {failedloginattempts = 0, loggedin = false, name = "R Briggs", password = "abc"}}
[cookie] expiry_days = 30 key = "somesignaturekey" # Must be string name = "somecookiename"
Reference: Deploying Streamlit-Authenticator via Streamlit Community Cloud
๐โ๏ธ Run the app using Streamlit
$ poetry shell
$ streamlit run app.py
๐ณ Run the app using Docker
- ๐ฝ Build image
$ docker compose build
- ๐โ๏ธ Run the app
$ docker compose up
Access to http://localhost:8501.
๐ Deploy to Streamlit Cloud
You can fork this repository and deploy the app to https://share.streamlit.io/. No need to run the app on your local machine.Don't forget to choose 3.10 as the Python version and set environment variables in the "Advanced settings" during deployment.
To use authentication with Streamlit Cloud, please use this TOML format:
# Environment variables
OpenAI settings
OPENAIAPIKEY="sk-xxx"
When using only one assistant, set the following, unset the OPENAI_ASSISTANTS variable.
ASSISTANTID="asstxxx"
ASSISTANT_TITLE="Assistants API UI" # This is for the single agent title
When using multiple assistants, set the following.
OPENAIASSISTANTS='[{"id": "asstxxx", "title": "Assistants XXX UI"}, {"id": "asst_yyy", "title": "Assistants YYY UI"}]'
App settings
ENABLEDFILEUPLOAD_MESSAGE="Upload a file" # Leave empty to disable
AUTHENTICATI # Must change to True if you require authentication
Authentication secrets
[credentials]
usernames = { jsmith = {failedloginattempts = 0, loggedin = false, name = "John Smith", password = "abc"}, rbriggs = {failedloginattempts = 0, loggedin = false, name = "R Briggs", password = "abc"}}
[cookie] expiry_days = 30 key = "somesignaturekey" # Must be string name = "somecookiename"