File size: 1,970 Bytes
45c65f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1f94008
45c65f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1f94008
 
45c65f8
 
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
79
80
81
                `# Dify Documentation Expert (RAG Chatbot)

A Retrieval-Augmented Generation (RAG) chatbot for Dify documentation, using MiniLM for semantic search and DistilBERT for answer generation. Built with Python, Flask, LangChain, and FAISS. Deployable on Vercel.

---

## Features
- Scrapes and processes Dify documentation
- Builds a FAISS vector store with MiniLM embeddings
- Uses DistilBERT for question answering
- Fast API with `/ask` and `/health` endpoints
- Ready for serverless deployment (Vercel)

---

## Project Structure
```
Dify-Expert/
β”œβ”€β”€ api/
β”‚   └── dify_api.py         # Flask API (entry point for Vercel)
β”œβ”€β”€ dify_docs_scraper/
β”‚   β”œβ”€β”€ dify_rag.py         # RAG logic (vector store + QA)
β”‚   β”œβ”€β”€ dify_faiss_index/   # FAISS index files
β”‚   └── ...                 # Scraper, processing scripts, etc.
β”œβ”€β”€ requirements.txt        # Python dependencies
β”œβ”€β”€ vercel.json             # Vercel config
β”œβ”€β”€ README.md               # This file
└── futurescope.md          # Project roadmap/ideas
```

---

## Quickstart

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

### 2. Build the vector store (if not already built)
```bash
python3 dify_docs_scraper/build_vector_store.py
```

### 3. Run locally (API)
```bash
python3 api/dify_api.py
```

### 4. Query the API
```bash
curl -X POST http://localhost:8000/ask \
  -H "Content-Type: application/json" \
  -d '{"question": "What is Dify?"}'
```

---

## Deployment (Vercel)
1. Push to GitHub.
2. Connect repo to Vercel.
3. Deploy (Vercel auto-detects Python from requirements.txt).
4. Endpoints:
   - `/ask` (POST)
   - `/health` (GET)

---

## API Endpoints
- `POST /ask` β€” `{ "question": "..." }` β†’ `{ "answer": ..., "score": ..., "sources": [...] }`
- `GET /health` β€” `{ "status": "ok" }`

---

## Roadmap
See [`futurescope.md`](futurescope.md) for planned features and ideas.

---

## License
MIT