Content
# Deepseek-Naga Emotion AI
An emotion AI chat program based on the DeepSeek API, featuring memory functionality and intelligent topic indexing.
## Features
- Basic emotional chat functionality
- Conversation history memory and context management
- Intelligent topic recognition and automatic indexing
- Simple and user-friendly interface
- Comprehensive logging system
## Usage
1. Configure the API key: Edit the config.py file and enter your DeepSeek API key.
2. Install dependencies: `pip install -r requirements.txt`
3. Run the program: `python main.py`
## Index Recording System
Naga has an intelligent index recording system that can:
1. Automatically record each conversation to a date file (e.g., `2025-04-19.txt`)
2. Automatically generate conversation topics when the number of conversations reaches a threshold or the user explicitly mentions "topic" related content
3. Save the generated topics to `summary.txt`, organized by date
4. Allow the AI to reference historical topic indexes when answering questions, enabling understanding of past conversations
### Topic Index Triggering Methods
- The number of conversations reaches the configured threshold (default is 5)
- The user mentions keywords such as "topic," "index," or "summary"
- The user can force an update by sending commands like "update index"
### Topic Generation Mechanism
The system uses AI to intelligently understand conversation content and generate topics, supporting multiple methods:
1. **Natural Language Embedded Index**: When the AI's reply contains a specific format `[Index Topic]: xxx[End]`, the system will automatically extract this part as the topic. This allows the AI to include index information in natural conversations without affecting overall expression.
2. **Automatic Index Generation**: When the user mentions keywords like "topic" or "index," or when the conversation reaches a certain number of exchanges, the system will automatically prompt the AI to generate a topic index.
3. **Standard Format Assurance**: The system ensures that all index topics follow a uniform format for easy viewing and understanding by users.
The AI is guided to naturally incorporate the index topic in its replies when users mention index-related content, for example:
```
User: Summarize our previous conversation
AI: We discussed the applications of artificial intelligence, and I believe the topic of this conversation is [Index Topic]: Discussion on AI Applications[End], covering three main areas: healthcare, education, and finance.
```
This approach ensures the AI's expression is natural and fluent while providing clear index information for the system.
### System Commands
The system supports the following special commands:
- `View Index`: Display all currently recorded conversation topic indexes
- `Update Index`: Force an update of the topic index file
- `Clear Screen`: Clear the terminal display content
- `Exit`: End the conversation and exit the program
### Index File Description
- `summary.txt`: Topic index file, an overview of conversation topics organized by date
- `index_metadata.json`: Index metadata, recording processed files and update times
## Directory Structure
- main.py: Main program entry
- conversation.py: Core conversation processing
- config.py: Global configuration file
- chatlog/: Directory for storing chat records and indexes
- summary.txt: Topic index file
- YYYY-MM-DD.txt: Conversation records stored by date
## Configuration Options
You can adjust the following configurations in `config.py`:
- MAX_HISTORY_ROUNDS: Number of historical conversation rounds to remember
- INDEX_DIALOG_THRESHOLD: Threshold for the number of conversations to automatically update the index
- DEBUG: Whether to enable debug logging