CoolFace
Apppublic

Shubham-10000/RAG-enabled-AI-assistant

sourceHugging Faceapache-2.0updated 11mo agoView on Hugging Face
1likes
App README

AI Assistant with RAG

An AI-powered assistant with Retrieval Augmented Generation (RAG) capabilities, running on Docker.

Features

  • โ€”๐ŸŽฏ Department-specific assistants: HR, Finance, IT, Product Manager
  • โ€”๐Ÿ“„ Document upload: Support for .txt and .md files
  • โ€”๐Ÿ” RAG (Retrieval Augmented Generation): Search and use uploaded documents as context
  • โ€”๐Ÿ’ฌ Multi-turn conversations: Maintains chat history
  • โ€”โš™๏ธ Adjustable settings: Control temperature and retrieval parameters
  • โ€”๐Ÿณ Docker deployment: Isolated and reproducible environment

How to Use

  1. 1.Configure API Key: Add your Groq API key in Space Settings โ†’ Repository secrets
  2. 2.Secret name: GROQ_API_KEY
  3. 3.Get free key: https://console.groq.com/
  1. 1.Select Department: Choose your department from the sidebar
  1. 1.Upload Documents (optional): Upload .txt or .md files for RAG
  1. 1.Enable RAG: Toggle RAG to use uploaded documents as context
  1. 1.Start Chatting: Type your message and press Enter

Technology Stack

  • โ€”LLM: Groq API (kimi-k2-instruct-0905)
  • โ€”Embeddings: Sentence Transformers (all-MiniLM-L6-v2)
  • โ€”Vector Search: FAISS
  • โ€”UI: Streamlit
  • โ€”Deployment: Docker

Setup (for local development)

bash
# Clone the repository
git clone https://huggingface.co/spaces/Shubham-10000/RAG-enabled-AI-assistant
cd ai-assistant-rag

# Create .env file
echo "GROQ_API_KEY=your_key_here" > .env

# Build and run with Docker
docker build -t ai-assistant .
docker run -p 7860:7860 --env-file .env ai-assistant

# Or use docker-compose
docker-compose up

Configuration

Environment Variables

  • โ€”GROQ_API_KEY: Your Groq API key (required)
  • โ€”GROQ_MODEL: Model to use (default:moonshotai/kimi-k2-instruct-0905)

Hugging Face Secrets

Add these in Space Settings โ†’ Repository secrets:

  • โ€”GROQ_API_KEY: Your Groq API key

Files Structure

.
โ”œโ”€โ”€ Dockerfile                 # Docker configuration
โ”œโ”€โ”€ requirements.txt           # Python dependencies
โ”œโ”€โ”€ app.py                    # Main Streamlit application
โ”œโ”€โ”€ storage.py                # Vector storage implementation
โ”œโ”€โ”€ .streamlit/
โ”‚   โ””โ”€โ”€ config.toml          # Streamlit configuration
โ”œโ”€โ”€ .dockerignore            # Docker ignore file
โ””โ”€โ”€ README.md                # This file

Limitations

โš ๏ธ Storage Note: Documents uploaded to Hugging Face Spaces are stored temporarily. They persist during the session but may be lost on Space restart.

For production use with permanent storage, consider:

  • โ€”Using external database (MongoDB, Supabase)
  • โ€”Implementing Hugging Face Datasets API
  • โ€”Self-hosting with persistent volumes

Development

Local Development without Docker

bash
# Install dependencies
pip install -r requirements.txt

# Set environment variable
export GROQ_API_KEY=your_key_here

# Run app
streamlit run app.py

Testing

bash
# Test with sample document
echo "Company Policy: Remote work allowed on Tuesdays and Thursdays" > test.txt

# Upload test.txt in the app
# Enable RAG
# Ask: "What is the remote work policy?"

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

Apache 2.0

Support

  • โ€”Issues: Report bugs or request features in the Issues tab
  • โ€”Documentation: https://huggingface.co/docs/hub/spaces
  • โ€”Groq API: https://console.groq.com/docs

Note: This Space requires a Groq API key to function. Get your free key at https://console.groq.com/