File size: 4,132 Bytes
95737e4 9f031f6 99db407 9f031f6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | ---
title: 9jaLingo Chatbot
emoji: "ποΈ"
colorFrom: blue
colorTo: green
sdk: docker
app_port: 7860
pinned: false
---
# 9jaLingo Bot
A minimal RAG-based customer support assistant for the 9jaLingo Voice AI platform, built with FastAPI, Chroma, and Ollama.
The bot is designed to answer user questions about 9jaLingo products and workflows, including Text-to-Speech (TTS), Speech-to-Text (STT), Voice Cloning, Voice Over production, API usage, and support operations.
## Features
- Intelligent support chat for 9jaLingo platform questions
- Retrieval-augmented responses using Chroma vector database
- Local embeddings with Ollama
- Conversation memory by `thread_id`
- FastAPI backend with `/chat` and `/stream` endpoints
## Core Platform Coverage
The support bot FAQ and retrieval context includes answers for:
- Product overview and account onboarding
- TTS voices, languages, and usage patterns
- STT transcription workflows and output formats
- Voice cloning requirements and best practices
- Voice over workflows for creators and agencies
- API authentication, request patterns, and integration guidance
- Billing, quotas, and usage troubleshooting
- Support and escalation guidance
## Prerequisites
- Python 3.12+
- uv (recommended package manager)
- Ollama installed locally
- Ollama model pulled locally:
- `embeddinggemma`
- API keys:
- Optional API keys only if your chosen Ollama setup requires them
## Installation
1. Clone repo and enter bot folder:
```bash
cd 9jalingo_bot
```
2. Install dependencies:
```bash
uv sync
```
3. Configure environment variables in `.env`:
```env
GOOGLE_API_KEY=your_google_api_key
TAVILY_API_KEY=your_tavily_api_key
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_EMBEDDING_MODEL=embeddinggemma
```
4. Confirm Ollama models are available:
```bash
ollama list
```
## Build Vector Database
From the project root (`9jalingo_bot`), run your vector DB bootstrap flow (if needed) so `data/faq.json` is indexed into Chroma.
Chroma persists locally under:
- `data/chroma_db/`
## Run API
```bash
uv run uvicorn main:app --reload --host 0.0.0.0 --port 8000
```
## API Endpoints
### Health
```http
GET /health
```
### Chat
```http
POST /chat
```
Request body:
```json
{
"message": "How do I start with voice cloning on 9jaLingo?",
"thread_id": "support-user-42"
}
```
### Stream
```http
POST /stream
```
## Project Structure
```text
9jalingo_bot/
βββ data/
β βββ faq.json
βββ src/
β βββ chat_service.py
β βββ chatbot.py
β βββ ingest.py
βββ rag/
β βββ data/
β βββ chroma_db/
βββ main.py
βββ pyproject.toml
βββ Readme.md
```
## Notes
- Embeddings and chat generation are handled through Ollama-backed components.
- The API uses the FAQ file in `data/faq.json` as the RAG knowledge source.
- Memory is keyed by `thread_id` and persisted to `data/conversation_memory.jsonl` by default.
- For Hugging Face persistent disk, set `RAG_MEMORY_FILE=/data/conversation_memory.jsonl` in Space variables.
## Deploy to Hugging Face (Docker Space)
This project is Docker-based and currently installs Python dependencies from `requirements.txt` in the Dockerfile.
1. Clone your Space repo:
```bash
git clone https://huggingface.co/spaces/9jaLingo/chatbot
cd chatbot
```
When prompted for password, use a Hugging Face access token with write permission.
2. Install Hugging Face CLI with uv:
```bash
uv tool install hf
```
3. (Optional) Verify/download Space files:
```bash
hf download 9jaLingo/chatbot --repo-type=space
```
4. Copy this app into the Space repo root (important files):
- `Dockerfile`
- `requirements.txt`
- `main.py`
- `src/`
- `data/`
- `.dockerignore`
5. Commit and push:
```bash
git add Dockerfile requirements.txt main.py src data .dockerignore Readme.md
git commit -m "Deploy 9jaLingo bot Docker Space"
git push
```
6. Hugging Face Docker Space requirement:
- The app must listen on port `7860` (already set in `Dockerfile`).
|