A FastAPI backend for document upload, storage, and chat-based querying using OpenAI and ChromaDB.
Includes a web UI for uploading documents and a Gradio-powered chat interface for interacting with your document collection.
- Drag and drop or select files at
/upload/ui - See uploaded files from the UI
- Go to
/chatto interact with your documents using natural language
- Upload and store documents (
.pdf,.docx,.txt,.html) via API or web UI - Documents are chunked and embedded using OpenAI embeddings, stored in ChromaDB
- Query your documents using natural language via a chat interface (Gradio)
- REST endpoints for listing, resetting, and querying documents
- Docker and Fly.io deployment ready
poetry installCopy .env.sample to .env and add your OpenAI API key:
OPENAI_API_KEY=your-openai-key
poetry run uvicorn filespeak_backend.main:app- Visit http://localhost:8000/upload/ui for the upload UI
- Visit http://localhost:8000/chat for the chat interface
POST /upload— Upload a single documentPOST /upload_multiple— Upload multiple documentsGET /ls— List all stored document IDsPOST /reset— Delete all documents from the collectionGET /query?query=...— Query the collection with a text prompt
See filespeak_backend/routers/documents.py for details.
- Drag and drop or select files at
/upload/ui - See uploaded files and reset the collection from the UI
- Go to
/chatto interact with your documents using natural language - Powered by Gradio and OpenAI GPT-4
Build and run with Docker:
docker build -t filespeak-backend .
docker run -p 8000:8000 --rm filespeak-backend- Install flyctl
- Set your app name in
fly.tomlandpyproject.toml - Deploy:
fly launchRun tests with:
poetry run pytestfilespeak_backend/
main.py # FastAPI app entrypoint
chat.py # Gradio chat interface
my_chromadb.py # ChromaDB client and collection setup
routers/
documents.py # Document upload/query endpoints
ui.py # HTML upload UI endpoint
static/
favicon.ico
tests/
test_ok.py
MIT
