File size: 1,723 Bytes
d383abe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# 🚀 Hugging Face Spaces Deployment Guide

## Quick Deployment Steps

### 1. Create a New Space

- Go to [Hugging Face Spaces](https://huggingface.co/spaces)
- Click "Create new Space"
- Choose "Streamlit" as the SDK
- Set visibility (Public/Private)

### 2. Upload Files

Upload these files to your Space:

- `app.py` (main Streamlit application)
- `requirements.txt` (dependencies)
- `README.md` (documentation)

### 3. Set Environment Variables

- Go to Settings → Secrets
- Add `GOOGLE_API_KEY` with your Gemini API key
- The app will automatically use this environment variable

### 4. Deploy

- Push your code to the Space
- The app will automatically build and deploy
- Wait for the build to complete (usually 2-3 minutes)

### 5. Test Your App

- Open your Space URL
- Enter your Gemini API key in the sidebar
- Click "Initialize RAG System"
- Start chatting!

## Important Notes

- **API Key**: Make sure to set `GOOGLE_API_KEY` in Space secrets
- **Memory**: The app will create a Chroma database in memory
- **Performance**: First initialization may take a few minutes
- **Limits**: Hugging Face Spaces have resource limits

## Troubleshooting

### Build Fails

- Check `requirements.txt` for correct package versions
- Ensure all imports are available

### Runtime Errors

- Verify API key is set correctly
- Check logs in the Space interface
- Ensure all dependencies are installed

### Performance Issues

- Reduce the number of documents processed
- Use smaller embedding models
- Optimize the RAG pipeline

## Customization

You can customize the app by:

- Modifying the UI in `app.py`
- Changing the embedding model
- Adjusting the RAG pipeline parameters
- Adding new features

Happy deploying! 🎉