RAG with sources, built with Dash, FastAPI, and the Databricks platform.
Here is an example of the app in action:
To install the project, ensure you have the following dependencies:
- 📦 uv: for managing the project
- 🚀 Databricks CLI: for deploying the app
- 🌐 Node.js: for building the UI
-
Clone the repo:
git clone <repo-url>
-
Run sync:
uv sync --all-packages
-
Configure environment variables in the
.env
file:# Name of your Databricks profile CHATTEN_PROFILE=... # Optionally, you can include any bundle or Chatten variables: CHATTEN_CATALOG=... # Optionally, by check default values in databricks.yml BUNDLE_VAR_vsi_endpoint=...
-
Start the UI watcher in one terminal:
cd packages/chatten_ui && npm run watch
-
Run the server in another terminal:
uvicorn chatten_app.app:app --reload
-
Authenticate with Databricks:
databricks auth login -p <profile-name>
-
Deploy the app:
# See Makefile for additional variables make deploy profile=fe-az-ws catalog=<catalog-name>
-
Run the RAG workflow:
# See Makefile for additional variables make run-rag profile=fe-az-ws catalog=<catalog-name>
-
Grant app principal access to the Volume.
-
Run the app:
make run-app profile=fe-az-ws catalog=<catalog-name>
-
Open the app from Databricks Workspace 🎉
Check the api_app
source code for details on how the agent serving endpoint response is parsed.
Specifically, the /chat
API endpoint handles:
- Parsing responses
- Sending messages to the chat interface
The implementation consists of a FastAPI backend with two sub-apps:
- Dash app (
/
route): Uses a custom component to render the chat UI. - FastAPI app (
/api
route): Provides API endpoints for the chat.
The chat is implemented as a custom Dash component, which is a React-based UI element that communicates with the FastAPI backend.
The /api
app interacts with the Databricks Serving Endpoint to handle chat requests and responses. Another route is responsible for serving PDF files from Databricks Volume.
📦 chatten # Main package (FastAPI + Dash app)
┣ 📂 packages/chatten_ui # Dash UI & custom chat component
┣ 📂 packages/chatten_rag # RAG workflow implementation
┣ 📂 packages/chatten_app # FastAPI & Dash apps
┣ 📂 src/chatten # Common config & utilities
┣ 📂 src/chatten/app.py # Main entry point
- Databricks
- Apps - App serving
- Asset Bundles - Deployment
- Mosaic AI Model Serving - Model serving
- Mosaic AI Vector Search - Vector search