File size: 2,409 Bytes
eab4de1 b8a537c | 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 | ---
title: Chat with Wiki Documents
emoji: π
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: "5.49.1"
app_file: app.py
pinned: false
---
# Chat with Wiki Documents
A Gradio application that allows you to chat with documents from any online wiki using Retrieval Augmented Generation (RAG).
## Features
- π Connect to any online wiki
- π Secure API key input
- π¬ Interactive chat interface
- π Automatic document fetching and processing
- π Semantic search across wiki content
- π€ Powered by OpenAI's GPT models
## Setup
1. **Install dependencies:**
```bash
pip install -r requirements.txt
```
2. **Get an OpenAI API key:**
- Sign up at [OpenAI](https://platform.openai.com/)
- Create an API key from your dashboard
3. **Run the application:**
```bash
python app.py
```
4. **Open your browser:**
- The app will be available at `http://localhost:7860`
- Or use the public URL provided in the terminal
## Usage
1. **Enter Wiki URL:** Paste the URL of the wiki you want to chat with
2. **Enter API Key:** Paste your OpenAI API key
3. **Click "Initialize RAG":** This will fetch and process the wiki content
4. **Start Chatting:** Ask questions about the wiki content in the chat interface
## How It Works
1. **Document Fetching:** The app fetches content from the specified wiki URL and follows links to gather multiple pages
2. **Text Processing:** Documents are split into chunks for efficient processing
3. **Embedding:** Text chunks are converted to embeddings using OpenAI's embedding model
4. **Vector Store:** Embeddings are stored in a ChromaDB vector database
5. **Retrieval:** When you ask a question, relevant chunks are retrieved using semantic search
6. **Generation:** The retrieved context is used to generate an answer using GPT
## Notes
- The app fetches up to 10 wiki pages by default
- Vector database is stored locally in `./chroma_db`
- Your API key is only used for API calls and not stored permanently
- Make sure the wiki URL is publicly accessible
## Troubleshooting
- **"Error fetching wiki content":** Check that the wiki URL is correct and publicly accessible
- **"Error initializing RAG":** Verify your API key is valid and has credits
- **Slow initialization:** Large wikis may take time to process. Be patient!
## License
MIT
|