A terminal-based chat system that combines the power of Large Language Models with RAG (Retrieval Augmented Generation) capabilities. This system allows for multiple chat sessions, document indexing, and context-aware responses.
- 💬 Multiple Chat Sessions: Create and manage multiple independent chat conversations
- 📄 Document Integration: Upload and index various document types for context
- 🔍 RAG-Powered Responses: All responses are enhanced with relevant context from indexed documents
- 🎨 Rich Formatting: Markdown support with syntax highlighting for code blocks
- 🔌 Pluggable Architecture: Easily swap LLM and embedding models
- 💾 Persistent Storage: All chats and indexed documents are saved to PostgreSQL
- 📱 Terminal UI: Clean and intuitive terminal-based user interface
- 🖼️ Image Support: Include images in your conversations
- ⚡ Fast Search: Vector-based similarity search for relevant context
- Clone the repository:
https://github.com/Bitsy-Chuck/context_aware_llm.git
cd context_aware_llm- Create a virtual environment and activate it:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Set up PostgreSQL database and set environment variables:
# Create database
createdb rag_chat
# Set environment variables
export ANTHROPIC_API_KEY="your-api-key"
export DATABASE_URL="postgresql://user:password@localhost:5432/rag_chat"The system uses a YAML configuration file located at config/default_config.yaml. You can customize:
- LLM model settings
- Embedding model parameters
- Database configuration
- Chunking and RAG parameters
- UI preferences
- Logging settings
Start the application:
python main.pyOr with custom configuration:
python main.py --config path/to/config.yaml --log-level DEBUG/new- Create a new chat session/switch <chat_id>- Switch to another chat/list- List all chats/upload- Upload and index a file/files- List indexed files/clear- Clear the screen/help- Show help information/exit- Exit application
rag_chat_system/
├── src/
│ ├── models/ # LLM and embedding model implementations
│ ├── database/ # Database and vector store management
│ ├── chat/ # Chat session and message handling
│ ├── indexing/ # Document processing and indexing
│ ├── utils/ # Utility functions and helpers
│ └── ui/ # Terminal UI implementation
├── config/ # Configuration files
└── main.py # Application entry point
Major dependencies include:
anthropic- Claude API clientsentence-transformers- For document embeddingsasyncpg- PostgreSQL async driverfaiss-cpu- Vector similarity searchrich- Terminal UI formattingprompt_toolkit- Interactive terminal interfacePyYAML- Configuration management
- Create a new class in
models/that inherits fromBaseLLM - Implement the required methods
- Update the configuration to use your new model
- Update
FileHelperinutils/file_helper.py - Add processing logic in
indexing/document_processor.py - Update supported file types in configuration
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Anthropic for the Claude API
- sentence-transformers for embedding capabilities
- FAISS for vector search
- Rich for terminal formatting
For support:
- Check the
/helpcommand in the application - Open an issue on GitHub
- Contact the maintenance team
- Python 3.8+
- PostgreSQL 12+
- 8GB RAM minimum (recommended)
- Anthropic API key