File size: 1,334 Bytes
6b27270
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
title: Book Model - RAG QA API
emoji: πŸ“š
colorFrom: blue
colorTo: purple
sdk: docker
pinned: false
license: mit
app_port: 7860
---

# Book Model β€” RAG Question Answering API

A Retrieval-Augmented Generation (RAG) API built with **FastAPI**, **FAISS**, **SentenceTransformers**, and **Groq LLM**.

## API Endpoints

| Method | Path | Description |
|--------|------|-------------|
| `GET` | `/` | Health message |
| `GET` | `/health` | Detailed system status |
| `POST` | `/query` | Ask a question against the indexed documents |
| `GET` | `/docs` | Interactive Swagger UI |

### Example β€” Query the API

```bash
curl -X POST "https://jeevant010-book-model.hf.space/query" \
  -H "Content-Type: application/json" \
  -d '{"query": "What is machine learning?", "top_k": 3}'
```

### Response

```json
{
  "query": "What is machine learning?",
  "answer": "Machine learning is ...",
  "sources": [
    {"index": 0, "distance": 0.42, "text": "..."}
  ]
}
```

## Environment Variables

Set `GROQ_API_KEY` as a **Secret** in your Hugging Face Space settings.

## Tech Stack

- **FastAPI** β€” async web framework
- **FAISS** β€” vector similarity search
- **SentenceTransformers** β€” embedding model (`all-MiniLM-L6-v2`)
- **Groq** β€” LLM inference (`llama-3.1-8b-instant`)
- **LangChain** β€” document loading & text splitting