File size: 1,384 Bytes
0931f56
 
 
 
 
 
9999649
 
0931f56
 
 
 
aa8691d
 
 
 
f7ef156
aa8691d
 
 
 
 
 
 
 
 
 
 
 
 
f7ef156
 
 
 
 
 
 
aa8691d
 
 
 
 
 
 
 
 
0931f56
aa8691d
 
0931f56
aa8691d
 
0931f56
f7ef156
 
 
 
 
 
 
 
 
 
 
9999649
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
---
title: RAG Chatbot Demo
emoji: 🤖
colorFrom: blue
colorTo: green
sdk: gradio
sdk_version: 6.13.0
python_version: '3.10'
app_file: app.py
pinned: false
---

# Demo RAG Chatbot

A Python demo chatbot that:

- loads configuration from environment variables or `config.yaml`
- scrapes the configured website
- builds embeddings using HuggingFace models
- retrieves relevant chunks (RAG)
- generates answers using SambaNova API
- returns formatted text output with citations

## Setup

1. Install dependencies:
   ```bash
   pip install -r requirements.txt
   ```

2. Configure environment variables:
   - `SAMBANOVA_API_KEY`: your SambaNova API key
   - `WEBSITE`: the URL to scrape
   - `EMBEDDING_MODEL`: HuggingFace model (default: `sentence-transformers/all-MiniLM-L6-v2`)
   - `SYSTEM_PROMPT`: optional behavior prompt

   Or create `config.yaml` with these keys.

## Run CLI Mode

```bash
python chatbot.py
```

Type a question and press Enter. Type `exit` to quit.

## Run with Gradio UI

```bash
python app.py
```

Interactive web interface with real-time answers and citations display.

## Hugging Face Spaces

For deployment on Hugging Face Spaces:

1. Set the following secrets in your Space settings:
   - `SAMBANOVA_API_KEY`
   - `WEBSITE`
   - `EMBEDDING_MODEL` (optional)
   - `SYSTEM_PROMPT` (optional)

2. The app will automatically use these environment variables.