File size: 1,679 Bytes
da3de1d
00011fa
 
 
 
da3de1d
 
 
 
00011fa
da3de1d
 
00011fa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
title: "RAG Chatbot — GPT-5.1 + URLs / Files / Text"
emoji: 🧠
colorFrom: indigo
colorTo: blue
sdk: gradio
sdk_version: 5.49.1
app_file: app.py
pinned: false
short_description: GPT-5.1 RAG chatbot for URLs, files, and text sources
---

# 🔍 RAG Chatbot — GPT-5.1 + URLs / Files / Text

A universal Retrieval-Augmented Generation (RAG) chatbot powered by **OpenAI GPT-5.1** and **Gradio 5.49.1**, enabling users to inject their own knowledge in real time — via **URLs**, **uploaded files**, or **raw text blocks** — and query it conversationally.

---

## 🚀 Features

- **OpenAI API key input** stored per session (no backend storage)  
- **GPT-5.1** model for chat; **text-embedding-3-large** for vector retrieval  
- Accepts:
  - Live **URLs** (auto-fetched text)
  - Uploaded **files** (`.txt`, `.md`, `.csv`, `.json`)
  - Custom **text areas** for notes or raw data  
- Interactive **presets** that auto-fill working examples (ZEN sites, policy QA, etc.)  
- **Retrieval debugging info** displayed transparently for testing relevance  
- **No external DB** — fully in-memory RAG layer for portability  
- Works in **Hugging Face Space**, **Google Colab**, or **local Python**

---

## 🧩 How It Works

1. Enter your **OpenAI API key** and click **Save**.  
2. Add knowledge sources (URLs, uploads, or text).  
3. Click **Build / Refresh Knowledge Base**.  
   - Text is chunked → embedded via `text-embedding-3-large`.  
   - Stored in memory as a lightweight vector index.  
4. Ask questions — the system retrieves relevant chunks and constrains GPT-5.1 to answer **only from those** and your **system instructions**.

---

## 🧱 File Structure