Isabella is an AI-powered chatbot with a terminal-style UI, featuring emotion detection capabilities. Built with React + TypeScript frontend and FastAPI backend, powered by LongCat API and advanced ML models for emotion analysis.
- About
- Quick Links
- Features
- Tech Stack
- Dependencies & Packages
- Installation
- Usage
- API Endpoints
- Folder Structure
- Development
- Environment Variables
- MongoDB Configuration
- Logging
- Contributing
- License
- Security
- Code of Conduct
- π€ AI-Powered Chat: Leverages LongCat API for intelligent conversations
- π¨ Terminal Aesthetic: Black background, green text, monospace font for authentic CLI feel
- π§ Thinking Mode Toggle:
- ON: Uses
LongCat-Thinkermodel (deeper reasoning) - OFF: Uses
LongCat-Flash-Chatmodel (faster responses)
- ON: Uses
- π Emotion Detection: Advanced ML-based emotion analysis using PyTorch and Transformers
- πΎ MongoDB Integration: Persistent chat history storage
- π Chat History: Loads last 50 messages on startup
- π Context Window: Sends last 10 messages to AI for conversation continuity
- π Comprehensive Logging: Detailed server-side logs for all operations
- π Auto-scroll: Chat window automatically scrolls to show new messages
- π Text-to-Speech: AI responses spoken using Piper TTS (local, offline)
- β‘ Single-page Application: No routing, streamlined UX
- π Type-safe Implementation: Full TypeScript for frontend reliability
- axios
^1.13.2- Promise-based HTTP client for API requests - react
^19.2.0- Core React library - react-dom
^19.2.0- React DOM rendering - react-markdown
^10.1.0- Markdown rendering in React
Dev/Build/Test Dependencies
- @eslint/js
^9.39.1- ESLint JavaScript configuration - @types/node
^24.10.0- TypeScript definitions for Node.js - @types/react
^19.2.2- TypeScript definitions for React - @types/react-dom
^19.2.2- TypeScript definitions for React DOM - @vitejs/plugin-react
^5.1.0- Vite plugin for React - eslint
^9.39.1- JavaScript/TypeScript linter - eslint-plugin-react-hooks
^5.2.0- ESLint rules for React Hooks - eslint-plugin-react-refresh
^0.4.24- ESLint plugin for React Fast Refresh - globals
^16.5.0- Global identifiers from different JavaScript environments - typescript
~5.9.3- TypeScript compiler - typescript-eslint
^8.46.3- TypeScript ESLint parser and plugin - vite
^7.2.2- Next-generation frontend build tool
- fastapi
0.115.0- Modern, fast web framework for building APIs - uvicorn
0.32.0- ASGI server implementation - httpx
0.27.2- Async HTTP client - python-dotenv
1.0.1- Environment variable management - motor
3.3.2- Async MongoDB driver - pymongo
4.6.1- MongoDB driver for Python - torch
>=2.0.0- PyTorch machine learning framework - transformers
>=4.30.0- Hugging Face transformers for NLP/ML
- Node.js 18+ and npm
- Python 3.8+
- MongoDB 7.0+ (locally or via Docker)
- Git
-
Install and start MongoDB:
# Using Docker (recommended) docker run -d -p 27017:27017 --name mongodb mongo:7.0 # Or install MongoDB locally and start it # mongod --dbpath /path/to/data
-
Navigate to the backend directory:
cd backend -
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Create a
.envfile with your LongCat API key:echo "LONGCAT_API_KEY=your_actual_api_key_here" > .env
-
Setup Piper TTS (Optional - for text-to-speech):
a. Download Piper TTS binary for your platform:
- Visit: https://github.com/rhasspy/piper/releases
- Download the appropriate version for your OS
- Extract and place the
piperexecutable inbackend/piper_tts/piper/
b. Download the en_US-amy-medium voice model:
- Visit: https://github.com/rhasspy/piper/releases/tag/2023.11.14-2
- Download
en_US-amy-medium.onnxanden_US-amy-medium.onnx.json - Place both files in
backend/piper_tts/
See
backend/piper_tts/README.mdfor detailed instructions.Note: TTS is optional. The chatbot will work without it.
-
Start the FastAPI server:
uvicorn main:app --reload --port 5000
The backend will run at:
http://localhost:5000
-
Install dependencies:
npm install
-
Start the development server:
npm run dev
The frontend will run at:
http://localhost:5173
- Open the frontend in your browser (
http://localhost:5173) - You'll see a terminal-style interface with:
- A "Thinking Mode" checkbox at the top
- A chat window showing conversation history
- An input box at the bottom for typing messages
- Toggle "Thinking Mode" to switch between AI models:
- β ON: Uses LongCat-Thinker (thoughtful, detailed responses)
- β¬ OFF: Uses LongCat-Flash-Chat (faster, concise responses)
- Type your message and press Enter or click SEND
- The AI response will appear in the terminal window
- The chat window will automatically scroll to show new messages
- If TTS is configured, AI responses will be spoken automatically
- Audio controls appear below each AI message for manual playback
Send a message to the AI chatbot.
Request Body:
{
"message": "Your question here",
"thinking": true
}Response:
{
"reply": "AI response here",
"audio_file": "speech_uuid.wav"
}Fetch the last 50 messages from chat history.
Response:
{
"messages": [
{
"_id": "...",
"role": "user",
"content": "Hello!",
"timestamp": "2025-11-10T14:02:31.537000",
"thinking": false,
"model": "LongCat-Flash-Chat"
}
]
}Generate speech from text using Piper TTS.
Request Body:
{
"text": "Text to convert to speech"
}Response:
{
"audio_file": "speech_uuid.wav"
}Retrieve a generated audio file.
Response:
- Audio file in WAV format
Isabella/
βββ src/ # Frontend React application
β βββ components/
β β βββ ChatWindow.tsx
β β βββ ThinkingToggle.tsx
β β βββ IsolateToggle.tsx
β βββ assets/
β βββ App.tsx
β βββ App.css
β βββ main.tsx
β βββ index.css
βββ backend/
β βββ config/ # Configuration modules
β β βββ database.py # MongoDB connection
β βββ models/ # Data models
β β βββ chat.py
β βββ routes/ # API routes
β β βββ chat.py
β β βββ tts.py
β βββ services/ # Business logic
β β βββ chat_service.py
β β βββ tts_service.py
β βββ ml_models/ # Machine learning models
β β βββ emotion_detector_model/
β βββ datasets/ # Training datasets
β β βββ emotion_detection_dataset/
β βββ tests/ # Backend tests
β β βββ test_emotion_integration.py
β β βββ test_timestamp_context.py
β βββ utils/ # Utilities
β β βββ logger.py
β βββ main.py # FastAPI entry point
β βββ requirements.txt
β βββ ARCHITECTURE.md
β βββ EMOTION_DETECTION.md
β βββ QUICKSTART_EMOTION.md
β βββ README.md
βββ public/
β βββ vite.svg
βββ .github/ # GitHub configuration
β βββ ISSUE_TEMPLATE/ # Issue templates
β βββ pull_request_template.md
βββ package.json
βββ package-lock.json
βββ tsconfig.json
βββ tsconfig.app.json
βββ tsconfig.node.json
βββ vite.config.ts
βββ eslint.config.js
βββ index.html
βββ README.md
βββ LICENSE
βββ CONTRIBUTING.md
βββ SECURITY.md
βββ CODE_OF_CONDUCT.md
npm run buildnpm run lintnpm run previewcd backend
python -m pytest tests/LONGCAT_API_KEY: Your LongCat API key (required)
The application uses MongoDB to store chat history:
- Connection URL:
mongodb://127.0.0.1:27017/isabella - Database:
isabella - Collection:
chats
{
"_id": ObjectId,
"role": String, // "user" or "assistant"
"content": String, // Message content
"timestamp": ISODate, // Message timestamp
"thinking": Boolean, // Thinking mode enabled
"model": String // AI model used
}The backend provides comprehensive logging for debugging and monitoring:
- MongoDB connection status
- All user messages and AI responses
- Context window contents (last 10 messages sent to AI)
- API calls and errors
- Database operations
- Emotion detection results
Check the server console for detailed logs of all operations.
We welcome contributions! Please see our Contributing Guidelines for details on:
- How to fork and contribute
- Code style and linting rules
- Bug reporting and feature requests
- Testing and documentation
This project is licensed under the MIT License - see the LICENSE file for details.
Security is important to us. Please see our Security Policy for information on:
- Reporting vulnerabilities
- Security contact information
- Vulnerability handling process
This project adheres to the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code.
- The backend must be running on port 5000 for the frontend to connect properly
- MongoDB must be running on port 27017 (default)
- Update the API URL in
App.tsxif deploying to production - For production use, configure CORS properly in
main.pywith specific allowed origins - The terminal styling uses monospace fonts and green (#0f0) text on black (#111) background
- Chat history is automatically loaded when the page loads
- The AI receives the last 10 messages as context for better conversation continuity
Made with β€ by H0NEYP0T-466