--- 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