This is an emotion detection AI application with local data storage capabilities, integrated with a local large language model.
- Support for local large models using GGUF format
- Real-time conversation streaming responses
- Conversation history saving and management
- Organize conversations using folders
- Favorite important conversations
- Markdown format support
- Dark/Light theme
- Model parameter customization (temperature, top_p)
- Adjustable conversation context size
- Frontend: React.js
- Backend: FastAPI
- Database: MongoDB
- Model: GGUF Local Large Language Model
- Node.js v16+
- Python 3.9+
- MongoDB (installed locally)
- Download and install MongoDB Community Edition from the MongoDB Official Website.
- Start the MongoDB service:
- Windows: Usually starts automatically as a service.
- Mac:
brew services start mongodb-community - Linux:
sudo systemctl start mongod
-
Download a GGUF Model: Obtain a compatible large language model in GGUF format. Here are the options available on Hugging Face:
-
Place the Model File: Create a directory named
modelin the root of this project (alongsidefrontendandbackend). Place the downloaded.gguffile inside thismodeldirectory./your-project-root ├── frontend/ ├── backend/ ├── model/ <-- Create this directory │ └── your_model_name.gguf <-- Place your model file here └── README.mdThe backend is configured to automatically find and load the first
.gguffile it finds within themodeldirectory upon startup.
-
Navigate to the backend directory:
cd backend -
Create a virtual environment:
python3 -m venv venv
-
Activate the virtual environment:
- Windows:
venv\Scripts\activate - macOS/Linux:
source venv/bin/activate
- Windows:
-
Install dependencies:
pip install -r requirements.txt
-
Start the backend service:
python3 app.py
The backend will run on
http://localhost:8000by default.
-
Navigate to the frontend directory:
cd frontend -
Install dependencies:
npm install
-
Start the frontend development server:
npm start
The frontend will open in your browser, usually at
http://localhost:3000. -
Register an Account: Once the frontend is running, navigate to the registration page (usually by clicking a "Register Now" or similar link on the login page) and create your user account through the UI.
You can customize the model's behavior by adjusting parameters in the settings menu (⚙️):
-
Temperature (0-1): Controls randomness in the model's responses. Lower values (closer to 0) make responses more deterministic and focused, while higher values (closer to 1) make them more creative and diverse. Default is 0.1.
-
Top P (0-1): Controls diversity via nucleus sampling. A value of 0.1 means only the most likely 10% of potential tokens are considered at each step. Default is 0.1.
-
Context Count (0-20): Controls how many previous messages are included when sending a new question. Setting to 0 means no conversation history is included (stateless mode). Default is 0.
The application supports organizing conversations into folders:
- All folders stay expanded by default for easy access
- You can create new folders by clicking the "+" button in the folders section
- Move conversations between folders using the context menu (•••)
Describes the structure of data stored in MongoDB.
Stores information about each chat session.
{
"_id": "ObjectId", // MongoDB's default primary key
"conversation_id": "string", // Unique identifier for the conversation (UUID)
"user_id": "string", // Identifier of the user who owns the conversation
"title": "string", // Title of the conversation (often auto-generated initially)
"preview": "string", // Short preview of the last user message
"lastUpdated": "datetime", // Timestamp of the last update to the conversation
"messages": [
{
"id": "number", // Sequential ID for the message within this conversation
"role": "string", // 'user' or 'assistant'
"content": "string", // Message content (can be Markdown)
"timestamp": "datetime", // Timestamp when the message was added
"edited": "boolean", // Optional: Flag indicating if the message was edited
"isHTML": "boolean" // Optional: Flag indicating if the content is raw HTML
}
// ... more messages
],
"favorite": "boolean", // Flag indicating if the conversation is marked as favorite
"folderId": "string" // ID of the folder this conversation belongs to (e.g., "default_<user_id>", "favorites_<user_id>", or custom folder UUID)
}Stores information about user-created folders for organizing conversations.
{
"_id": "ObjectId", // MongoDB's default primary key
"folder_id": "string", // Unique identifier for the folder (e.g., "default_<user_id>", "favorites_<user_id>", or custom UUID)
"user_id": "string", // Identifier of the user who owns the folder
"name": "string" // Name of the folder (e.g., "Default", "Favorites", "Project X")
}Stores user account information.
{
"_id": "ObjectId", // MongoDB's default primary key
"user_id": "string", // Unique identifier for the user (UUID)
"username": "string", // Login username (must be unique)
"display_name": "string", // Name displayed in the UI
"password_hash": "string", // Hashed password (using SHA-256 in this example)
"created_at": "datetime", // Timestamp when the user account was created
"last_login": "datetime" // Optional: Timestamp of the last successful login
}GET /api/conversations- Get all conversationsGET /api/conversations/{conversation_id}- Get a specific conversationPOST /api/conversations- Create a new conversationPUT /api/conversations/{conversation_id}- Update a conversation (e.g., title, favorite, folderId)DELETE /api/conversations/{conversation_id}- Delete a conversationPOST /api/conversations/{conversation_id}/messages- Add a message to a conversation (primarily handled by chat endpoints now)
GET /api/folders- Get all foldersPOST /api/folders- Create a new folderPUT /api/folders/{folder_id}- Update a folder (e.g., rename)DELETE /api/folders/{folder_id}- Delete a folder
POST /api/chat- Send a chat message (potentially non-streaming)POST /api/chat/stream- Send a chat message and receive a streamed response, supports temperature and top_p parameters




