File size: 1,606 Bytes
5beaa02
 
 
 
 
 
8ff1aa9
144b1bd
5beaa02
 
 
 
 
1357c97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
title: Document Assistant
emoji: 📄
colorFrom: blue
colorTo: yellow
sdk: gradio
sdk_version: 5.4.0
python_version: "3.11"
app_file: app.py
pinned: false
---

# Document Assistant (SPJIMR Branded)

A simple, document-aware chatbot built with Gradio, FAISS, and Hugging Face Inference API.

## Features
- **File Support**: PDF, DOCX, TXT.
- **RAG Engine**: Uses `Sentence-Transformers` for embeddings and `FAISS` for fast retrieval.
- **UI**: Customized Gradio Blocks with SPJIMR branding (Deep Blue & Gold).
- **LLM**: Powered by Mistral-7B via Hugging Face Inference API.

## Local Setup
1. Clone this repository.
2. Install dependencies:
   ```bash
   pip install -r requirements.txt
   ```
3. Set your Hugging Face Token (required for LLM access):
   - Windows (PowerShell): `$env:HF_TOKEN="your_token_here"`
   - Linux/Mac: `export HF_TOKEN="your_token_here"`
4. Run the app:
   ```bash
   python app.py
   ```

## Deployment to Hugging Face Spaces
1. Create a new Space on [Hugging Face](https://huggingface.co/new-space).
2. Select **Gradio** as the SDK.
3. Upload `app.py` and `requirements.txt`.
4. Go to **Settings** > **Variables and Secrets**.
5. Add a new **Secret**:
   - Key: `HF_TOKEN`
   - Value: Your Hugging Face User Access Token (from [hf.co/settings/tokens](https://huggingface.co/settings/tokens)).
6. The Space will build and deploy automatically!

## Built with
- [Gradio](https://gradio.app/)
- [FAISS](https://github.com/facebookresearch/faiss)
- [Sentence-Transformers](https://www.sbert.net/)
- [Hugging Face Inference API](https://huggingface.co/docs/api-inference/index)