- π¬ OpenAI Assistants API chat UI
- π οΈ It works easily by setting the ASSISTANT IDs
- π Supports file upload and file download
- π Supports Streaming API
- π₯ Supports multiple Assistant profiles in one place
- πͺ Support to Azure OpenA
- β» Cannot be used until Azure OpenAI Service supports Streaming API
![γΉγ―γͺγΌγ³γ·γ§γγ 2023-11-20 2 23 51](https://private-user-images.githubusercontent.com/6661165/284078100-5c288d51-196a-4919-bc4d-dc508146f58a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQwMDc1NjMsIm5iZiI6MTcyNDAwNzI2MywicGF0aCI6Ii82NjYxMTY1LzI4NDA3ODEwMC01YzI4OGQ1MS0xOTZhLTQ5MTktYmM0ZC1kYzUwODE0NmY1OGEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgxOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MThUMTg1NDIzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZTM4Mzk0OTdiOTczZDM3MDI0NjU3OTk2YTBkM2JkZDBkMDMzZGI1YmVmNDg0YTQxOTQ2MGY1MWNjNjVjY2Q0OSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.A35q8PXXQyfBhA3fyDNQXIdkxoWP1vSHL8V1R2r2m8U)
-
π€ 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 OPENAI_API_KEY="sk-xxx" APP_ENABLED_FILE_UPLOAD_MESSAGE="Upload a file" # Leave empty to disable AUTHENTICATION_REQUIRED="False" # Must change to True if you require authentication # When using only one assistant, set the following, unset the OPENAI_ASSISTANTS variable. ASSISTANT_ID="asst_xxx" ASSISTANT_TITLE="Assistants API UI" # This is for the single agent title # When using multiple assistants, set the following. OPENAI_ASSISTANTS='[{"id": "asst_xxx", "title": "Assistants XXX UI"}, {"id": "asst_yyy", "title": "Assistants YYY UI"}]'
If you use azure instead, set
AZURE_OPENAI_ENDPOINT
andAZURE_OPENAI_KEY
-
π Set Authentication configuration (optional)
To set up authentication, create a secrets file
.streamlit/secrets.toml
as below:[credentials] usernames = { jsmith = {failed_login_attempts = 0, logged_in = false, name = "John Smith", password = "abc"}, rbriggs = {failed_login_attempts = 0, logged_in = false, name = "R Briggs", password = "abc"}} [cookie] expiry_days = 30 key = "some_signature_key" # Must be string name = "some_cookie_name"
Reference: Deploying Streamlit-Authenticator via Streamlit Community Cloud
$ poetry shell
$ streamlit run app.py
-
π½ Build image
$ docker compose build
-
πβοΈ Run the app
$ docker compose up
Access to http://localhost:8501.
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
OPENAI_API_KEY="sk-xxx"
APP_ENABLED_FILE_UPLOAD_MESSAGE="Upload a file" # Leave empty to disable
AUTHENTICATION_REQUIRED="False" # Must change to True if you require authentication
# When using only one assistant, set the following, unset the OPENAI_ASSISTANTS variable.
ASSISTANT_ID="asst_xxx"
ASSISTANT_TITLE="Assistants API UI" # This is for the single agent title
# When using multiple assistants, set the following.
OPENAI_ASSISTANTS='[{"id": "asst_xxx", "title": "Assistants XXX UI"}, {"id": "asst_yyy", "title": "Assistants YYY UI"}]'
# Authentication secrets
[credentials]
usernames = { jsmith = {failed_login_attempts = 0, logged_in = false, name = "John Smith", password = "abc"}, rbriggs = {failed_login_attempts = 0, logged_in = false, name = "R Briggs", password = "abc"}}
[cookie]
expiry_days = 30
key = "some_signature_key" # Must be string
name = "some_cookie_name"