DashGPT is a template for user-friendly chat interfaces for LLM chat models. It's built with Plotly Dash and provides a seamless experience on both desktop and mobile platforms. This template is setup to use OpenAI's API's but can be adapted to use other LLM's.
This template supports:
โจ Retrieval-augmented generation
๐ User feedback functionality
โ๏ธ Custom user settings and user guides
๐ก Text streaming functionality
๐ฑ Optimized for mobile and desktop
Demo Site: https://dashgpt.live
- Clone the repo
- Create a virtual environment with Python 3.11
- Install the requirements from
requirements.txt
- Fill in the the
.env_TEMPLATE
file and rename it to.env
- Run the app using
python src/dashgpt/app.py
- Got to
http://localhost:8050/
in your browser to use it!
This repository includes a ChromDB vector database with a sample of 2000 Reddit Jokes embedded. When a question is asked the top 3 most similar jokes to the question are retrieved and used as the context for the LLM. The LLM then generates a response to the question.
In the response the similar jokes are provided in a drop-down accordion element to show how you might display sources of information to the user.
The text streaming functionality was gratefully adapted from danton267's dash-streaming-GPT-app and built on top of to add functionality.
From his README on how the text streaming works:
- User types in the prompt
- User presses send button
- This triggers clientside callback JS function
- JS function makes a
await fetch("/streaming-chat"
request to the Dash server- in Dash, we create
@app.server.route("/streaming-chat", methods=["POST"])
route to receive response from the JS function - We retrieve all parameters from the request, process them, and send them to the OpenAI API
- We return
Response yield object
to the JS function
- in Dash, we create
- JS function processess the response and starts appending incoming text to the
innerHTML
of theresponse window element
There is also a second clientside callback which disables the submit button so that it can not be pressed while the request is being processed.
To demonstrate the incorporation of retrieval-augmented generation, we use the Reddit Jokes dataset. The dataset is available here: https://github.com/taivop/joke-dataset/blob/master/reddit_jokes.json
The dataset is loaded into a ChromaDB vector database for local prototyping and demo purposes. You can switch out the Vector DB fairly easily.
There are two ways, either with standard Plotly Dash call to app.py
which uses a development server locally.
python src/dashgpt/app.py
To test a "production" server we need to use waitress
as gunicorn
is Linux only. To run the app using waitress
use the following command:
waitress-serve --listen=localhost:8050 src.dashgpt.app:flask_server
For deploying the web app to Azure or running on a Linux VM we can use gunicorn
which should use the following command:
gunicorn --bind=0.0.0.0 --timeout 600 src.dashgpt.app:flask_server
Contributions are welcome! Please read the contributing guidelines before starting.
If you encounter any issues or have questions, please open an issue.
This project is licensed under the Creative Commons Attribution-Sharealike 4.0 license. See the LICENSE file for more details or here: https://creativecommons.org/licenses/by-sa/4.0/