Latest version: 0.9.3
WebUI (streamlit-based) to ChatGPT and Dall-E's API (requires an OpenAI API key).
The tool's purpose is to enable a company to install a self-hosted version of a WebUI to access the capabilities of OpenAI's ChatGPT and DallE and share access to the tool's capabilities while consolidating billing through the OpenAI API key. Access to models is limited to those enabled with your API key.
Click on the links to see a screenshot of the GPT WebUI and the DallE WebUI.
Please see https://github.com/Infotrend-Inc/OpenAI_WebUI/blob/main/.env.example for details of possible values for the environment variables. Unless specified, even if a feature is not used, its environment variable should be set.
A pre-built container is available from our Docker account at https://hub.docker.com/r/infotrend/openai_webui
An Unraid-ready version is available directly from Unraid's `Community Applications``.
Note: this tool was initially developed in February 2023 and released to help end-users.
The tool provides a WebUI to ChatGPT and Dall-E (that later one can be disabled).
The tool requires the use of an OpenAI API key to work. Check at https://platform.openai.com/account/api-keys to find yours.
Depending on your deployment solution (python virtualenv, docker image, or unraid), the deployment might differ slightly.
Once started, the WebUI will prompt the end user with a username
.
This username is here to make finding past conversations/images easier if you seek those; no authentication is associated with it.
ChatGPT (Text Generation) sidebar options (see "?" mark for specific details):
- model: choose between the different ChatGPT models that are enabled.
- role (user, system, assistant): define the role of the input text for tailored responses.
- max tokens: controls the length of generated text with a maximum token setting (dependent on the model)
- temperature: adjust the "surprisingness" of the generated text.
DALL-E (Image Generation) sidebar options (see "?" for specific details):
- mode: "image" for the time being.
- model: choose between the different DallE models that are enabled.
- image Size: specify the dimensions of the images to be generated.
- number of images (model dependent): number of images to generate
- quality (model dependent): fine-tune image quality to meet your requirements.
- style (model dependent): style of the generated images.
We have added means to inform the end-user when a model is retired
, legacy
or current
.
retired
models are not available for use anymore.legacy
models will be retired at a specified date.current
models are available.
The tool will automatically discard known (per the release) retired
models and inform the end user.
Similarly, the tool will note when a model is legacy
.
Please update your model selection accordingly.
The models.json file contains the list of models supported by each release (as introduced in v0.9.3). The following table shows the models listed in this file as well as the release it was added to:
Mode | Model | Status | Notes | From |
---|---|---|---|---|
DallE | dalle-e-2 | active | 0.9.3 | |
DallE | dalle-e-3 | active | 0.9.3 | |
GPT | gpt-3.5-turbo | active | 0.9.3 | |
GPT | gpt-3.5-turbo-0125 | active | 0.9.3 | |
GPT | gpt-3.5-turbo-0613 | legacy | Will be deprecated on June 13, 2024 | 0.9.3 |
GPT | gpt-3.5-turbo-1106 | active | 0.9.3 | |
GPT | gpt-3.5-turbo-16k | legacy | Will be deprecated on June 13, 2024 | 0.9.3 |
GPT | gpt-3.5-turbo-16k-0613 | legacy | Will be deprecated on June 13, 2024 | 0.9.3 |
GPT | gpt-4 | active | 0.9.3 | |
GPT | gpt-4-0125-preview | active | 0.9.3 | |
GPT | gpt-4-0613 | active | 0.9.3 | |
GPT | gpt-4-1106-preview | active | 0.9.3 | |
GPT | gpt-4-32k | active | 0.9.3 | |
GPT | gpt-4-32k-0613 | active | 0.9.3 | |
GPT | gpt-4-turbo-preview | active | 0.9.3 |
Once a model is retired
, using it in your models list will have it discarded from the available list with a notification.
Similarly, if a used model is listed as legacy
, a notification of the upcoming deprecation will be shown in the UI.
The .env.example
file contains the parameters needed to pass to the running tool:
OPENAI_API_KEY
as obtained from https://platform.openai.com/account/api-keysOAIWUI_SAVEDIR
, the location to save content (make sure the directory exists)OAIWUI_GPT_ONLY
, to request only to show the GPT tab otherwise, shows both GPT and DallE (authorized value:True
orFalse
)OAIWUI_GPT_MODELS
is a comma-separated list of GPT model(s) your API key is authorized to use. See https://platform.openai.com/docs/api-reference/making-requests for more information.OAIWUI_DALLE_MODELS
is a comma-separated list of DallE model(s) your API key is authorized to use.OAIWUI_USERNAME
(optional) specifies ausername
and avoids being prompted at each re-run. The default mode is to run in multi-user settings so this is not enabled by default.
Those values can be passed by making a .env
file containing the expected values or using environment variables.
The .env
file is not copied into the docker
or unraid
setup. Environment variables should be used in this case.
The OAIWUI_SAVEDIR
variable specifies the location where persistent files will be created from run to run.
Its structure is: savedir
/version
/username
/mode
/UTCtime
/<CONTENT>
, with:
username
being the self-specified user name prompted when starting the WebUIversion
the tool's version, making it easier to debugmode
on ofgpt
ordalle
- the
UTCtime
, aYYYYY-MM-DD T HH:MM:SS Z
UTC-time of the request (the directory's content will be time ordered) <CONTENT>
is often ajson
file containing the details of the run forgpt
, but also the differentpng
images generated fordalle
We do not check the directories for size. It is left to the end user to clean up space if required.
This mode is for use if you have python3
installed and want to test the tool.
-
Create and activate your virtual environment
$ python3 -m venv venv $ source venv/bin/activate
-
Install the requirements within our activated virtual environment
$ pip install -U pip $ pip3 install --trusted-host pypi.org --trusted-host files.pythonhosted.org -r requirements.txt
-
Copy the default
.env.example
file as.env
, and manually edit the copy to add your OpenAI API key and the preferred save directory (which must exist before starting the program). You can also configure the GPTmodels
you can access with ChatGPT and disable the UI for Dall-E if preferred. Do not distribute that file.$ cp .env.example .env $ code .env
-
For developers, edit the code as you would, and when you are ready to test, start the WebUI.
$ streamlit run ./OpenAI_WebUI.py --server.port=8501 --server.address=127.0.0.1 --logger.level=debug
-
You can now open your browser to http://127.0.0.1:8501 to test the WebUI.
The container build is an excellent way to test in an isolated, easily redeployed environment.
This setup prefers the use of environment variable, using docker run ... -e VAR=val
-
Build the container
$ make build_main
-
Run the built container, here specifying your
OAIWUI_SAVEDIR
to be/iti
, which will be mounted from the current working directory'ssavedir
and mounted to/iti
within the container:$ docker run --rm -it -p 8501:8501 -v `pwd`/savedir:/iti -e OPENAI_API_KEY="Your_OpenAI_API_Key" -e OAIWUI_SAVEDIR=/iti -e OAIWUI_GPT_ONLY=False -e OAIWUI_GPT_MODELS="gpt-3.5-turbo,gpt-4" -e OAIWUI_DALLE_MODELS="dall-e-2,dall-e-3" openai_webui:latest
You can have the Makefile
delete locally built containers:
$ make delete_main
For Unraid users, a special build mode is available to get a container using unraid's preferred uid
/gid
, use make build_unraid
to build it.
The pre-built container has been added to Unraid's Community Applications.
- If you run into an error when starting the tool. Clear the
streamlit
cache (right side menu) or deleting cookies should solve this.
- v0.9.3 (20240306): Simplifying integration of new models and handling/presentation of their status (active, legacy, retired) + Cleaner handling of max_tokens vs context window tokens + updated openai python package to 1.13.3
- v0.9.2 (20241218): Keep prompt history for a given session + allow user to review/delete past prompts + updated openai python package: 1.8.0
- v0.9.1 (20231120): Print
streamlit
errors in case of errors with environment variables + Addition ofgpt-3.5-turbo-1106
in the list of supported models (added in openai python package 1.3.0) + added optionalOAIWUI_USERNAME
environment variable - v0.9.0 (20231108): Initial release -- incorporating modifications brought by the latest OpenAI Python package (tested against 1.2.0)
- Oct 2023: Preparation for public release
- Feb 2023: Initial version
This project includes contributions from Yan Ding and Muhammed Virk in March 2023.