--- title: RADHA emoji: 💜 colorFrom: purple colorTo: pink sdk: docker pinned: false --- # R.A.D.H.A - Responsive And Deeply Human Assistant An intelligent AI assistant built with FastAPI, LangChain, Groq AI, and a modern glass-morphism web UI. RADHA provides two chat modes (General and Realtime with web search), streaming responses, text-to-speech, voice input, and learns from your personal data files. Everything runs on one server with one command. --- ## Table of Contents - [Quick Start](#quick-start) - [Features](#features) - [How It Works (Full Workflow)](#how-it-works-full-workflow) - [Architecture](#architecture) - [Project Structure](#project-structure) - [API Endpoints](#api-endpoints) - [Configuration](#configuration) - [Technologies Used](#technologies-used) - [Frontend Guide](#frontend-guide) - [Troubleshooting](#troubleshooting) - [Developer](#developer) --- ## Quick Start ### Prerequisites - **Python 3.10+** with pip - **OS**: Windows, macOS, or Linux - **API Keys** (set in `.env` file): - `GROQ_API_KEY` (required) - Get from https://console.groq.com You can use **multiple Groq API keys** (`GROQ_API_KEY_2`, `GROQ_API_KEY_3`, ...) for automatic fallback when one hits rate limits or fails. - `TAVILY_API_KEY` (optional, for Realtime mode) - Get from https://tavily.com ### Installation 1. **Clone or download** this repository. 2. **Install dependencies**: ```bash pip install -r requirements.txt ``` 3. **Create a `.env` file** in the project root: ```env GROQ_API_KEY=your_groq_api_key_here # Optional: multiple keys for fallback when one hits rate limit # GROQ_API_KEY_2=second_key # GROQ_API_KEY_3=third_key TAVILY_API_KEY=your_tavily_api_key_here # Optional GROQ_MODEL=llama-3.3-70b-versatile ASSISTANT_NAME=Radha RADHA_USER_TITLE=Sir TTS_VOICE=en-IN-NeerjaNeural TTS_RATE=+22% ``` 4. **Start the server**: ```bash python run.py ``` 5. **Open in browser**: http://localhost:8000 That's it. The server hosts both the API and the frontend on port 8000. --- ## Features ### Chat Modes - **General Mode**: Pure LLM responses using Groq AI. Uses your learning data and conversation history as context. No internet access. - **Realtime Mode**: Searches the web via Tavily before answering. Smart query extraction converts messy conversational text into focused search queries. Uses advanced search depth with AI-synthesized answers. ### Text-to-Speech (TTS) - Server-side TTS using `edge-tts` (Microsoft Edge's free cloud TTS, no API key needed). - Audio is generated on the server and streamed inline with text chunks via SSE. - Sentences are detected in real time as text streams in, converted to speech in background threads (ThreadPoolExecutor), and sent to the client as base64 MP3. - The client plays audio segments sequentially in a queue — speech starts as soon as the first sentence is ready, not after the full response. - Works on all devices including iOS (uses a persistent `