A full-stack conversational AI system featuring Isabella, a sassy AI assistant powered by RAG (Retrieval-Augmented Generation) and comprehensive logging.
β οΈ Security Note: Letta personality engine is disabled by default due to known vulnerabilities. See SECURITY.md for details. Isabella's personality is maintained through LLM system prompts.
- π Personality: Isabella - your sassy, confident AI assistant with attitude
- π RAG System: FAISS-based document retrieval for knowledge-enhanced responses
- π¬ Real-time Chat: Terminal-style chat interface with monospace fonts
- π¨ Rich Rendering: Full support for Markdown, LaTeX, code syntax highlighting, and tables
- π Document Upload: Support for .txt, .md, .pdf, and .docx files (backend API)
- π Rich Logging: Comprehensive colored console logs tracking every step
- πΎ MongoDB Storage: Persistent conversation history
- π Security: Updated dependencies with patched vulnerabilities
- π Letta Integration: Optional personality engine (see LETTA_INFO.md)
βΉοΈ Learn about Letta: For detailed information about Letta personality engine, how it works, and implementation details, see LETTA_INFO.md
- FastAPI with async support (v0.109.1+ - patched)
- MongoDB for data persistence
- FAISS-CPU for vector similarity search
- Sentence-transformers for embeddings
- Letta for personality management (optional - see LETTA_INFO.md)
- LongCat LLM API integration
- Rich library for beautiful console logging
- Modern React 19 with TypeScript
- Zustand for state management
- Axios for API communication
- Terminal-style UI with monospace fonts
- React-Markdown for Markdown rendering
- KaTeX for LaTeX math rendering
- React-Syntax-Highlighter for code blocks
- Full table rendering support
Backend β Full list with exact versions & security patches in backend/requirements.txt
Frontend β Full list with exact versions in package.json
All dependencies are kept up-to-date with patched vulnerabilities (see SECURITY.md).
- Node.js 20+ and npm
- Python 3.9+
- MongoDB (local or remote)
- LongCat API Key (Get one here)
git clone https://github.com/H0NEYP0T-466/lettaXrag.git
cd lettaXragcd backend
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Create .env file
cp .env.example .env
# Edit .env and add your API keys
nano .env # or use your favorite editorRequired Environment Variables (.env):
MONGODB_URI=mongodb://localhost:27017/lettaXrag
LONGCAT_API_KEY=your_actual_api_key_here
# Letta - Local Server (Recommended)
LETTA_BASE_URL=http://localhost:8283
# No LETTA_API_KEY needed for local server
# Letta - Cloud Server (Alternative)
# LETTA_BASE_URL=https://api.letta.com
# LETTA_API_KEY=your_letta_cloud_api_key_here
# Optional
DATA_FOLDER=./data
FAISS_INDEX_PATH=./storage/faiss_index.bin
LOG_LEVEL=DEBUGπ Letta Local Server Setup: If you want to use Letta personality engine with a local server, see backend/letta.txt for detailed setup instructions including PostgreSQL configuration and troubleshooting.
# From root directory
npm install
# Create .env file
cp .env.example .env
# Edit if needed (default: http://localhost:8000)Add your knowledge base documents to the backend/data folder:
cd backend/data
# Add your .txt, .md, .pdf, or .docx files hereThe system will automatically index them on startup!
Terminal 1 - Backend:
cd backend
source venv/bin/activate # On Windows: venv\Scripts\activate
python main.pyThe backend will start on http://localhost:8000
Terminal 2 - Frontend:
npm run devThe frontend will start on http://localhost:5173
- Open your browser to
http://localhost:5173 - Type your question in the terminal-style input box
- Press Enter or click [send]
- Isabella will respond using her personality and knowledge base!
The chat interface features:
- Black background with green and cyan text (terminal aesthetic)
- Monospace font (Courier New) throughout
- Minimal design - no gradients, just clean text
- Rich content rendering:
- Markdown formatting (headers, lists, bold, italic, links)
- LaTeX math equations (inline:
$...$and display:$$...$$) - Code blocks with syntax highlighting
- Tables with proper formatting
- Blockquotes and other Markdown features
Documents can be uploaded via the API endpoint:
curl -X POST http://localhost:8000/api/upload \
-F "file=@/path/to/document.pdf"The system will automatically re-index and Isabella can use this knowledge!
When Isabella uses documents to answer your question:
- Click "π Show Sources" on her message
- See which documents she referenced
Send a message to Isabella
Request:
{
"message": "What is RAG?",
"session_id": "optional-session-id"
}Response:
{
"response": "RAG stands for...",
"rag_sources": ["document1.pdf", "notes.md"],
"timestamp": "2026-01-20T12:00:00"
}Check system health status
Upload a new document for indexing
Get system statistics (message count, indexed documents)
- User sends message β Frontend
- Frontend POST to
/api/chatβ Backend - Backend logs user prompt with Rich
- Letta processes message (adds personality)
- RAG retrieves relevant context from FAISS
- Constructs final prompt with context
- Sends to LongCat LLM API
- Logs LLM response
- Saves to MongoDB
- Returns to frontend
- Frontend displays Isabella's response
For Letta-based personality, edit backend/services/letta_service.py:
self.persona = """Your custom personality here..."""For LLM-based personality (when Letta is disabled), edit backend/services/llm_service.py:
system_prompt = """Your custom personality..."""See LETTA_INFO.md for detailed information about personality management.
Edit backend/services/rag_service.py:
def retrieve_context(self, query: str, k: int = 5): # Change k value
# Adjust chunk_size and overlap in _chunk_text()Edit backend/services/llm_service.py:
temperature=0.7, # Adjust creativity (0.0-1.0)
max_tokens=1000, # Adjust response lengthlettaXrag/
βββ backend/
β βββ main.py # FastAPI entry point
β βββ config.py # Configuration
β βββ requirements.txt # Python dependencies
β βββ models/
β β βββ schemas.py # Pydantic models
β βββ services/
β β βββ db_service.py # MongoDB operations
β β βββ rag_service.py # FAISS RAG system
β β βββ letta_service.py # Personality engine
β β βββ llm_service.py # LongCat integration
β βββ routes/
β β βββ chat.py # API endpoints
β βββ utils/
β β βββ logger.py # Rich logging
β β βββ file_watcher.py # Data folder monitor
β βββ data/ # Your documents
β βββ storage/ # FAISS index storage
βββ src/
β βββ components/ # React components
β βββ services/ # API client
β βββ hooks/ # Custom React hooks
β βββ store/ # Zustand store
β βββ types/ # TypeScript types
βββ package.json
# Make sure MongoDB is running
sudo systemctl start mongodb # Linux
brew services start mongodb-community # macOS# Delete and rebuild index
rm backend/storage/*
# Restart backend - it will rebuild automaticallyThe system will continue without Letta if initialization fails. Isabella will still work but without personality processing.
Common causes:
- Letta server not running (if using local server)
- Wrong LETTA_BASE_URL configuration
- PostgreSQL not running (if Letta is configured to use it)
Solutions:
- See backend/letta.txt for comprehensive Letta setup guide
- Check your
.envfile has:LETTA_BASE_URL=http://localhost:8283 - Make sure Letta server is running:
letta server - Or disable Letta by commenting out LETTA_BASE_URL in
.env
# Change backend port in main.py
uvicorn.run("main:app", host="0.0.0.0", port=8001)
# Update frontend .env
VITE_API_URL=http://localhost:8001- β Dependencies Updated: All known vulnerabilities patched
β οΈ Letta Disabled: Library has unpatched vulnerabilities (see SECURITY.md)- π Environment Variables: Never commit your
.envfile - π API Keys: Keep your API keys secure and rotate regularly
- π CORS: Use environment-specific CORS settings in production
- π File Uploads: Implement size limits and validation in production
- π Authentication: Add user authentication before production deployment
- π‘οΈ Rate Limiting: Implement rate limiting for production use
For Production Deployment: See the production security checklist in SECURITY.md
MIT License - feel free to use this project as you wish!
Contributions are welcome! Please feel free to submit a Pull Request.
For issues and questions, please open an issue on GitHub.
Made with π by the LettaXRAG Team