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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
|
| 17 |
|
| 18 |
-
|
| 19 |
-
forums](https://discuss.streamlit.io).
|
|
|
|
| 1 |
+
# ๐ถ๏ธ Matrix AI Chat with RAG
|
| 2 |
+
|
| 3 |
+

|
| 4 |
+

|
| 5 |
+

|
| 6 |
+

|
| 7 |
+
|
| 8 |
+
**Enter the Matrix** - An advanced AI chat interface with Retrieval-Augmented Generation (RAG) capabilities, featuring multiple AI models and a cyberpunk Matrix-themed UI.
|
| 9 |
+
|
| 10 |
+
## ๐ Live Demo
|
| 11 |
+
|
| 12 |
+
Visit the live deployment: [Matrix AI Chat Space](https://huggingface.co/spaces/YOUR_USERNAME/matrix-ai-chat)
|
| 13 |
+
|
| 14 |
+
## โจ Features
|
| 15 |
+
|
| 16 |
+
### ๐ค Multi-Model AI Support
|
| 17 |
+
- **DeepSeek-R1**: Advanced reasoning model via Together AI
|
| 18 |
+
- **Llama-3.2-3B**: Meta's efficient language model
|
| 19 |
+
- **Qwen2.5-VL-7B-Instruct**: Vision-language model via Hyperbolic
|
| 20 |
+
|
| 21 |
+
### ๐ง Retrieval-Augmented Generation (RAG)
|
| 22 |
+
- Upload and index custom documents
|
| 23 |
+
- Semantic similarity search using sentence transformers
|
| 24 |
+
- Context-aware responses based on your data
|
| 25 |
+
- Persistent document storage with embeddings
|
| 26 |
+
|
| 27 |
+
### ๐พ Smart Memory System
|
| 28 |
+
- Conversation history persistence
|
| 29 |
+
- Session management with UUID tracking
|
| 30 |
+
- Similarity-based response caching
|
| 31 |
+
- Automatic context generation from chat history
|
| 32 |
+
|
| 33 |
+
### ๐จ Matrix-Themed Interface
|
| 34 |
+
- Cyberpunk green-on-black Matrix aesthetic
|
| 35 |
+
- Glowing text effects and animations
|
| 36 |
+
- Terminal-style fonts (Courier New)
|
| 37 |
+
- Immersive digital realm experience
|
| 38 |
+
|
| 39 |
+
### ๐ง Advanced Controls
|
| 40 |
+
- Customizable system prompts
|
| 41 |
+
- Session management (new sessions, data purging)
|
| 42 |
+
- Real-time model status indicators
|
| 43 |
+
- Comprehensive configuration panel
|
| 44 |
+
|
| 45 |
+
## ๐ ๏ธ Setup & Installation
|
| 46 |
+
|
| 47 |
+
### For Hugging Face Spaces Deployment
|
| 48 |
+
|
| 49 |
+
1. **Fork or duplicate this Space**
|
| 50 |
+
2. **Set your Hugging Face Token**:
|
| 51 |
+
- Go to Space Settings โ Repository secrets
|
| 52 |
+
- Add `HF_TOKEN` with your Hugging Face API token
|
| 53 |
+
- Ensure your token has inference API access
|
| 54 |
+
|
| 55 |
+
3. **Configure the Space**:
|
| 56 |
+
```yaml
|
| 57 |
+
# In your Space's README.yml header
|
| 58 |
+
title: Matrix AI Chat with RAG
|
| 59 |
+
emoji: ๐ถ๏ธ
|
| 60 |
+
colorFrom: black
|
| 61 |
+
colorTo: green
|
| 62 |
+
sdk: streamlit
|
| 63 |
+
sdk_version: 1.28.0
|
| 64 |
+
app_file: app.py
|
| 65 |
+
pinned: false
|
| 66 |
+
license: mit
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
### For Local Development
|
| 70 |
+
|
| 71 |
+
1. **Clone the repository**:
|
| 72 |
+
```bash
|
| 73 |
+
git clone https://huggingface.co/spaces/YOUR_USERNAME/matrix-ai-chat
|
| 74 |
+
cd matrix-ai-chat
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
2. **Install dependencies**:
|
| 78 |
+
```bash
|
| 79 |
+
pip install -r requirements.txt
|
| 80 |
+
```
|
| 81 |
+
|
| 82 |
+
3. **Set environment variables**:
|
| 83 |
+
```bash
|
| 84 |
+
export HF_TOKEN="your_hugging_face_token_here"
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
4. **Run the application**:
|
| 88 |
+
```bash
|
| 89 |
+
streamlit run app.py
|
| 90 |
+
```
|
| 91 |
+
|
| 92 |
+
## ๐ Requirements
|
| 93 |
+
|
| 94 |
+
Create a `requirements.txt` file with:
|
| 95 |
+
|
| 96 |
+
```txt
|
| 97 |
+
streamlit>=1.28.0
|
| 98 |
+
numpy>=1.24.0
|
| 99 |
+
sentence-transformers>=2.2.2
|
| 100 |
+
scikit-learn>=1.3.0
|
| 101 |
+
transformers>=4.30.0
|
| 102 |
+
torch>=2.0.0
|
| 103 |
+
huggingface-hub>=0.16.0
|
| 104 |
+
openai>=1.0.0
|
| 105 |
+
uuid
|
| 106 |
+
```
|
| 107 |
+
|
| 108 |
+
## ๐ฏ Usage Guide
|
| 109 |
+
|
| 110 |
+
### Basic Chat
|
| 111 |
+
1. Select your preferred AI model from the sidebar
|
| 112 |
+
2. Enter your message in the chat input
|
| 113 |
+
3. Watch as the Matrix processes your query with streaming effects
|
| 114 |
+
|
| 115 |
+
### RAG Document Upload
|
| 116 |
+
1. Open the "UPLOAD DATA" section in the sidebar
|
| 117 |
+
2. Provide a title and content for your document
|
| 118 |
+
3. Click "INJECT DATA" to add it to the knowledge base
|
| 119 |
+
4. The system will automatically reference relevant documents in responses
|
| 120 |
|
| 121 |
+
### Session Management
|
| 122 |
+
- **NEW JACK IN**: Start a fresh conversation session
|
| 123 |
+
- **PURGE ALL**: Clear all stored data (requires confirmation)
|
| 124 |
+
- Sessions are automatically saved with persistent IDs
|
| 125 |
+
|
| 126 |
+
### Advanced Configuration
|
| 127 |
+
- Customize system prompts to change AI behavior
|
| 128 |
+
- Monitor connection status for each model
|
| 129 |
+
- View document count in your knowledge base
|
| 130 |
+
|
| 131 |
+
## ๐ API Keys & Tokens
|
| 132 |
+
|
| 133 |
+
This application requires a **Hugging Face API Token** with inference access:
|
| 134 |
+
|
| 135 |
+
1. Visit [Hugging Face Settings](https://huggingface.co/settings/tokens)
|
| 136 |
+
2. Create a new token with "Inference API" permissions
|
| 137 |
+
3. Add the token to your Space secrets or environment variables
|
| 138 |
+
|
| 139 |
+
**Supported Providers:**
|
| 140 |
+
- Together AI (via Hugging Face)
|
| 141 |
+
- Hyperbolic (via Hugging Face Router)
|
| 142 |
+
- Local Hugging Face models
|
| 143 |
+
|
| 144 |
+
## ๐ Project Structure
|
| 145 |
+
|
| 146 |
+
```
|
| 147 |
+
matrix-ai-chat/
|
| 148 |
+
โโโ app.py # Main Streamlit application
|
| 149 |
+
โโโ requirements.txt # Python dependencies
|
| 150 |
+
โโโ README.md # This file
|
| 151 |
+
โโโ data/ # Auto-created data directory
|
| 152 |
+
โ โโโ sessions/ # Chat session storage
|
| 153 |
+
โ โโโ documents/ # RAG document storage
|
| 154 |
+
โ โโโ embeddings/ # Vector embeddings
|
| 155 |
+
โโโ .gitignore # Git ignore file
|
| 156 |
+
```
|
| 157 |
+
|
| 158 |
+
## ๐จ Important Notes
|
| 159 |
+
|
| 160 |
+
### Data Persistence
|
| 161 |
+
- All data is stored locally in the `data/` directory
|
| 162 |
+
- Sessions, documents, and embeddings persist between app restarts
|
| 163 |
+
- Use "PURGE ALL" to completely reset the system
|
| 164 |
+
|
| 165 |
+
### Model Limitations
|
| 166 |
+
- API-based models require active internet connection
|
| 167 |
+
- Local models may have slower inference times
|
| 168 |
+
- Token limits apply based on your Hugging Face plan
|
| 169 |
+
|
| 170 |
+
### Security Considerations
|
| 171 |
+
- Keep your HF_TOKEN secure and private
|
| 172 |
+
- Documents uploaded are stored locally in the Space
|
| 173 |
+
- Session data is tied to browser sessions
|
| 174 |
+
|
| 175 |
+
## ๐ Troubleshooting
|
| 176 |
+
|
| 177 |
+
### Common Issues
|
| 178 |
+
|
| 179 |
+
**"No Hugging Face token found"**
|
| 180 |
+
- Ensure `HF_TOKEN` is set in your environment or Space secrets
|
| 181 |
+
- Verify your token has inference API permissions
|
| 182 |
+
|
| 183 |
+
**Model connection failed**
|
| 184 |
+
- Check your internet connection
|
| 185 |
+
- Verify your HF token is valid and has sufficient quota
|
| 186 |
+
- Try switching to a different model
|
| 187 |
+
|
| 188 |
+
**Embedding errors**
|
| 189 |
+
- Ensure sufficient memory for sentence transformer models
|
| 190 |
+
- Check if the embedding model downloaded successfully
|
| 191 |
+
|
| 192 |
+
**Data not persisting**
|
| 193 |
+
- Verify write permissions to the `data/` directory
|
| 194 |
+
- Check available disk space
|
| 195 |
+
|
| 196 |
+
## ๐ค Contributing
|
| 197 |
+
|
| 198 |
+
1. Fork the Space or repository
|
| 199 |
+
2. Create a feature branch
|
| 200 |
+
3. Make your improvements
|
| 201 |
+
4. Test thoroughly with different models
|
| 202 |
+
5. Submit a pull request
|
| 203 |
+
|
| 204 |
+
## ๐ License
|
| 205 |
+
|
| 206 |
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
| 207 |
+
|
| 208 |
+
## ๐ Acknowledgments
|
| 209 |
+
|
| 210 |
+
- **Hugging Face** for the amazing model ecosystem and Spaces platform
|
| 211 |
+
- **Streamlit** for the intuitive web app framework
|
| 212 |
+
- **The Matrix** films for the visual inspiration
|
| 213 |
+
- **SentenceTransformers** for semantic similarity capabilities
|
| 214 |
+
- **Together AI** and **Hyperbolic** for API access
|
| 215 |
+
|
| 216 |
+
## ๐ฎ Future Enhancements
|
| 217 |
+
|
| 218 |
+
- [ ] Multi-modal support (image uploads)
|
| 219 |
+
- [ ] Voice chat integration
|
| 220 |
+
- [ ] Advanced RAG with document chunking
|
| 221 |
+
- [ ] Real-time collaboration features
|
| 222 |
+
- [ ] Custom model fine-tuning interface
|
| 223 |
+
- [ ] Export/import chat sessions
|
| 224 |
+
- [ ] Advanced analytics dashboard
|
| 225 |
+
|
| 226 |
+
---
|
| 227 |
|
| 228 |
+
**Welcome to the Matrix. Red pill or blue pill? The choice is yours.** ๐ถ๏ธ
|
| 229 |
|
| 230 |
+
[](https://huggingface.co/spaces/YOUR_USERNAME/matrix-ai-chat)
|
|
|