- 🐾 Multi-character Pets: Switch between different pet avatars (catgirl, loyal dog, etc.), each with unique personality and conversation style
- 💬 Intelligent Conversation: Natural language interaction powered by LLM with streaming response support
- 🔧 Tool Calling: Pets can call various tools (alarm clock, timer, weather query, web browsing, etc.)
- 💾 Memory System: Automatically summarize chat content, remember owner's preferences, hobbies, and important dates
- 🎨 Interface Customization: Customize pet appearance, name, and conversation themes
- 📊 Affection System: Increase intimacy with pets through continuous interaction
- 🌐 Browser Access: Interact with pets via browser, suitable for environments without desktop
- 📱 Responsive Design: Adapts to different screen sizes
┌─────────────────────────────────────────────────────────────────┐
│ Client │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────┐ ┌─────────────────┐ │
│ │ Desktop App │ │ Web Frontend │ │
│ │ (PySide6) │ │ (HTML/JS) │ │
│ │ │ │ │ │
│ │ ┌───────────┐ │ │ FastAPI │ │
│ │ │ ChatAgent │ │ │ Server │ │
│ │ │ (Singleton)│ │ │ (web/server.py) │ │
│ │ └─────┬─────┘ │ └────────┬────────┘ │
│ │ │ HTTP │ │ │
│ │ │ Request │ │ HTTP Proxy │
│ └────────┼────────┘ │ │
│ │ │ │
└───────────┼───────────────────────────────┼──────────────────────┘
│ │
▼ ▼
┌─────────────────────────────────────────────────────────────────┐
│ Server Side │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ FastAPI Server (rag_server.py) │ │
│ │ │ │
│ │ ┌──────────────┐ ┌──────────────┐ ┌────────────┐ │ │
│ │ │ Chat API │ │ RAG │ │ Tavily │ │ │
│ │ │ Routes │ │ (Milvus) │ │ Search │ │ │
│ │ └──────┬───────┘ └──────┬───────┘ └────────────┘ │ │
│ │ │ │ │ │
│ │ └───────────┬───────┘ │ │
│ │ ▼ │ │
│ │ ┌──────────────┐ │ │
│ │ │ LangChain │ │ │
│ │ │ Chain │ │ │
│ │ └──────┬───────┘ │ │
│ │ │ │ │
│ └─────────────────────┼────────────────────────────────────┘ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ vLLM (Qwen3-30B) │ │
│ │ Locally Deployed LLM │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
└──────────────────────────────────────────────────────────────────┘
| Component | Technology | Description |
|---|---|---|
| UI Framework | PySide6 | Qt for Python, cross-platform desktop UI |
| HTTP Client | requests | Remote service communication |
| Automation | PyAutoGUI | Mouse and keyboard operations in tool calls |
| System Tools | ctypes, subprocess | DPI awareness, system command execution |
| Component | Technology | Description |
|---|---|---|
| Web Framework | FastAPI | High-performance Python web framework |
| LLM Inference | vLLM | Qwen3-30B-A3B-GPTQ-Int4 |
| Vector Database | Milvus | RAG retrieval augmentation |
| Embedding | HuggingFace | all-MiniLM-L6-v2 |
| Prompt Framework | LangChain | Chain composition and retrieval |
| Web Search | Tavily | Real-time information retrieval |
local_pet/
├── src/ # Desktop app main directory
│ ├── main.py # App entry, desktop pet main window
│ ├── link_model.py # Model connection layer
│ │ ├── ChatAgent # Conversation agent (singleton)
│ │ │ ├── Streaming # ask_stream() with SSE support
│ │ │ │ dialogue processing
│ │ │ ├── Tool call # XML tag format parsing
│ │ │ │ parsing
│ │ │ ├── Memory # update_history_memory()
│ │ │ │ summarization
│ │ │ └── System prompt # update_system_prompt()
│ │ │ management
│ │ └── LocalLLM # HTTP client
│ ├── window_tool.py # Tool executor (singleton)
│ │ ├── open_app() # Launch applications
│ │ ├── type_text() # Simulate keyboard input
│ │ ├── click() # Mouse click
│ │ ├── run_shell() # Execute shell commands
│ │ ├── press_keys() # Hotkey operations
│ │ ├── open_url() # Open URLs
│ │ ├── get_current_address() # Get current location
│ │ ├── get_today_weather() # Query today's weather
│ │ ├── get_future_weather() # Query weather forecast
│ │ ├── get_current_time() # Get current time
│ │ └── get_holiday_json() # Query lunar holidays
│ ├── file_load.py # Resource config loader
│ │ └── ResourceExtractor # Handle packaged resource paths
│ ├── string_manager.py # Multi-language string manager
│ ├── logger.py # Logging module
│ ├── ai_agent.py # AI Agent (reserved)
│ ├── config/ # Config files
│ │ ├── setting.ini # Main config
│ │ │ ├── [Url] # Server address
│ │ │ ├── [SessionID] # Session ID
│ │ │ ├── [General_Set] # Current pet index
│ │ │ ├── [Memory] # Memory storage
│ │ │ └── [Nick_Name] # Pet nickname
│ │ ├── pet_config_private.ini # Pet appearance config
│ │ ├── string_table.json # Dialogue templates & role definitions
│ │ └── holiday.json # Holiday data
│ ├── ui/ # UI modules
│ │ ├── mainUi.py # Main window UI
│ │ ├── chat_ui.py # Chat interface
│ │ ├── favor.py # Affection management
│ │ ├── login.py # Login window
│ │ ├── memoryDialog.py # Memory editor
│ │ ├── messageInfo.py # Message list model
│ │ ├── messageUi.py # Message bubble component
│ │ └── loadingUi.py # Loading animation overlay
│ ├── pet_image/ # Pet animation resources
│ │ └── model1.gif # Pet GIF animation
│ └── package.bat # Nuitka packaging script
│
├── backend/ # Server-side code
│ └── rag-milvus-project/
│ ├── rag_server.py # FastAPI main service
│ │ ├── /chat # Chat endpoint (streaming)
│ │ ├── /clear_history # Clear session history
│ │ └── /debug_history # Debug endpoint
│ ├── rag_chat.py # RAG Chain implementation
│ ├── ingest_data.py # Vector data import
│ ├── milvus_demo.db # SQLite metadata storage
│ ├── system_prompt.json # System prompt config
│ └── requirements.txt # Python dependencies
│
├── web/ # Web frontend
│ ├── server.py # FastAPI service
│ │ ├── /api/config # Get config
│ │ ├── /api/favor/list # Pet list & affection
│ │ ├── /api/favor/select # Switch pet
│ │ └── /api/favor/reset # Reset settings
│ ├── index.html # Main page
│ ├── components.js # Frontend components
│ ├── window_tool.py # Web version tools
│ └── config/ # Web config
│
├── README.md
└── .gitignore
User Input
│
▼
┌─────────────────────────────────────┐
│ 1. Check for Image │
│ - Extract <question>image:path │
│ - Base64 encode and send │
└─────────────────┬───────────────────┘
│
▼
┌─────────────────────────────────────┐
│ 2. Send Request to vLLM Server │
│ POST /chat │
│ - question: User question │
│ - session_id: Session ID │
│ - character: Current role key │
│ - memory: Memory context │
│ - image: Base64 image data │
└─────────────────┬───────────────────┘
│
▼
┌─────────────────────────────────────┐
│ 3. Parse Streaming Response │
│ - <think> Thinking process │
│ - <tool> Tool call instruction │
│ - <observation> Tool result │
│ - <final answer> Final answer │
└─────────────────┬───────────────────┘
│
┌───────┴───────┐
▼ ▼
┌─────────────┐ ┌─────────────┐
│ Needs Tool │ │ Direct │
│ Call │ │ Answer │
└──────┬──────┘ └──────┬──────┘
▼ │
┌─────────────┐ │
│ WindowTool │ │
│ Execute │ │
└──────┬──────┘ │
▼ │
└────────┬────────┘
▼
Display Final Answer
The pet communicates with backend using XML tags. Examples:
# When setting an alarm
<tool>to_set_clock_alarm("06:30")</tool>
# After tool execution
<observation>Alarm set for 06:30</observation>
# Final answer
<final answer>Your alarm is set! Remember to wake up on time~</final answer>
┌─────────────┐ Scheduled ┌─────────────┐
│ Chat Logs │ ──────────────▶│ LLM Summary │
│ (logs/*.txt)│ │ Extract prefs│
└─────────────┘ └──────┬──────┘
│
▼
┌─────────────┐
│ setting.ini │
│ [Memory] │
│ current_ │
│ memory │
└─────────────┘
[Url]
server_url = http://101.43.33.48:43351 # Remote vLLM server address
[SessionID]
id = "user001" # Session unique ID
[General_Set]
current_index = 2 # Current pet index (1=Liubai, 2=Qirui)
[Nick_Name]
nickname1 = Liubai # Pet nickname
nickname2 = Qirui
[Memory]
current_memory = Owner: likes badminton; hates tomatoes # Memory summary
current_file = # Current log file index| Key | Description |
|---|---|
Character_1 |
Catgirl role: tsundere but kindhearted, silver-white fur, blue eyes |
Character_2 |
Loyal dog role: sincere and soft, black fur, golden eyes |
Extra_Rule |
General rules: tool call format, thinking process |
New_Character_* |
Web simplified role definition |
Summary_Prompt |
Memory summarization prompt template |
- Python 3.8+
- Conda environment (recommended)
- Windows 10/11 (desktop app)
- Network access to remote server
# Activate Conda environment
conda activate local_pet
# Enter src directory
cd src
# Run app
python main.py# Enter web directory
cd web
# Install dependencies
pip install -r requirements.txt
# Run service
python server.py
# Access http://localhost:8000cd backend/rag-milvus-project
# Start vLLM (requires pre-deployment)
python -m vllm.entrypoints.openai.api_server \
--model Qwen/Qwen3-30B-A3B-GPTQ-Int4 \
--host localhost --port 8001
# Start RAG service
python rag_server.pycd src
# Run packaging script (requires Conda env)
python package.bat
# Output: build/main.dist/main.exePackage options:
--standalone: Standalone package with all dependencies--enable-plugin=pyside6: Enable PySide6 plugin--windows-console-mode=force: Keep console (for debugging)--lto=yes: Link-time optimization
PySide6>=6.5.0
requests>=2.28.0
pyautogui>=0.4.14
pygetwindow>=0.0.9
lunar-python>=1.15
chardet>=4.0.0
fastapi>=0.100.0
uvicorn>=0.23.0
langchain>=0.1.0
langchain-community>=0.0.10
langchain-openai>=0.0.2
langchain-huggingface>=0.0.1
langchain-milvus>=0.0.1
pymilvus>=2.3.0
huggingface-hub>=0.19.0
tavily-python>=0.3.0
fastapi>=0.100.0
uvicorn>=0.23.0
MIT License
- 🐾 多角色宠物:支持切换不同宠物形象(猫娘、忠犬等),每种角色有独特的性格和对话风格
- 💬 智能对话:基于大语言模型的自然语言交互,支持流式响应
- 🔧 工具调用:宠物可调用多种工具(闹钟、定时器、天气查询、网页打开等)
- 💾 记忆系统:自动摘要聊天内容,记住主人的偏好、爱好和重要日期
- 🎨 界面定制:支持自定义宠物外观、名称和对话主题
- 📊 好感度系统:通过持续互动提升与宠物的亲密度
- 🌐 浏览器访问:可通过浏览器与宠物互动,适合无桌面环境的场景
- 📱 响应式设计:适配不同屏幕尺寸
┌─────────────────────────────────────────────────────────────────┐
│ 客户端 │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────┐ ┌─────────────────┐ │
│ │ 桌面应用 │ │ Web 前端 │ │
│ │ (PySide6) │ │ (HTML/JS) │ │
│ │ │ │ │ │
│ │ ┌───────────┐ │ │ FastAPI │ │
│ │ │ ChatAgent │ │ │ Server │ │
│ │ │ (单例模式) │ │ │ (web/server.py)│ │
│ │ └─────┬─────┘ │ └────────┬────────┘ │
│ │ │ HTTP │ │ │
│ │ │ 请求 │ │ HTTP 代理 │
│ └────────┼────────┘ │ │
│ │ │ │
└───────────┼───────────────────────────────┼──────────────────────┘
│ │
▼ ▼
┌─────────────────────────────────────────────────────────────────┐
│ 服务器端 │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ FastAPI Server (rag_server.py) │ │
│ │ │ │
│ │ ┌──────────────┐ ┌──────────────┐ ┌────────────┐ │ │
│ │ │ Chat API │ │ RAG 检索 │ │ Tavily │ │ │
│ │ │ 路由 │ │ (Milvus) │ │ 联网搜索 │ │ │
│ │ └──────┬───────┘ └──────┬───────┘ └────────────┘ │ │
│ │ │ │ │ │
│ │ └───────────┬─────┘ │ │
│ │ ▼ │ │
│ │ ┌──────────────┐ │ │
│ │ │ LangChain │ │ │
│ │ │ Chain │ │ │
│ │ └──────┬───────┘ │ │
│ │ │ │ │
│ └─────────────────────┼───────────────────────────────────┘ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ vLLM (Qwen3-30B) │ │
│ │ 本地部署的 LLM 服务 │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
└──────────────────────────────────────────────────────────────────┘
| 组件 | 技术 | 说明 |
|---|---|---|
| UI 框架 | PySide6 | Qt for Python,跨平台桌面 UI |
| HTTP 客户端 | requests | 与远程服务通信 |
| 自动化工具 | PyAutoGUI | 工具调用中的鼠标键盘操作 |
| 系统工具 | ctypes, subprocess | DPI 感知、系统命令执行 |
| 组件 | 技术 | 说明 |
|---|---|---|
| Web 框架 | FastAPI | 高性能 Python Web 框架 |
| LLM 推理 | vLLM | Qwen3-30B-A3B-GPTQ-Int4 |
| 向量数据库 | Milvus | RAG 检索增强 |
| Embedding | HuggingFace | all-MiniLM-L6-v2 |
| 提示词框架 | LangChain | Chain 组合与检索 |
| 联网搜索 | Tavily | 实时信息检索 |
local_pet/
├── src/ # 桌面应用主目录
│ ├── main.py # 应用入口,桌面宠物主窗口
│ ├── link_model.py # 模型连接层
│ │ ├── ChatAgent # 对话代理(单例模式)
│ │ │ ├── 流式对话处理 # ask_stream() 支持 SSE
│ │ │ ├── 工具调用解析 # XML 标签格式解析
│ │ │ ├── 记忆摘要更新 # update_history_memory()
│ │ │ └── 系统提示词管理 # update_system_prompt()
│ │ └── LocalLLM # HTTP 客户端
│ ├── window_tool.py # 工具执行器(单例模式)
│ │ ├── open_app() # 启动应用程序
│ │ ├── type_text() # 模拟键盘输入
│ │ ├── click() # 鼠标点击
│ │ ├── run_shell() # 执行 Shell 命令
│ │ ├── press_keys() # 快捷键操作
│ │ ├── open_url() # 打开网址
│ │ ├── get_current_address() # 获取当前位置
│ │ ├── get_today_weather() # 查询今日天气
│ │ ├── get_future_weather() # 查询天气预报
│ │ ├── get_current_time() # 获取当前时间
│ │ └── get_holiday_json() # 查询农历节日
│ ├── file_load.py # 资源配置加载器
│ │ └── ResourceExtractor # 处理打包后的资源路径
│ ├── string_manager.py # 多语言字符串管理
│ ├── logger.py # 日志模块
│ ├── ai_agent.py # AI Agent(预留)
│ ├── config/ # 配置文件
│ │ ├── setting.ini # 主配置
│ │ │ ├── [Url] # 服务器地址
│ │ │ ├── [SessionID] # 会话标识
│ │ │ ├── [General_Set] # 当前宠物索引
│ │ │ ├── [Memory] # 记忆存储
│ │ │ └── [Nick_Name] # 宠物昵称
│ │ ├── pet_config_private.ini # 宠物外观配置
│ │ ├── string_table.json # 对话模板与角色定义
│ │ └── holiday.json # 节日数据
│ ├── ui/ # UI 模块
│ │ ├── mainUi.py # 主窗口 UI
│ │ ├── chat_ui.py # 聊天界面
│ │ ├── favor.py # 好感度管理
│ │ ├── login.py # 登录窗口
│ │ ├── memoryDialog.py # 记忆编辑
│ │ ├── messageInfo.py # 消息列表模型
│ │ ├── messageUi.py # 消息气泡组件
│ │ └── loadingUi.py # 加载动画覆盖层
│ ├── pet_image/ # 宠物动画资源
│ │ └── model1.gif # 宠物 GIF 动画
│ └── package.bat # Nuitka 打包脚本
│
├── backend/ # 服务器端代码
│ └── rag-milvus-project/
│ ├── rag_server.py # FastAPI 主服务
│ │ ├── /chat # 对话接口(支持流式)
│ │ ├── /clear_history # 清理会话历史
│ │ └── /debug_history # 调试接口
│ ├── rag_chat.py # RAG Chain 实现
│ ├── ingest_data.py # 向量数据导入
│ ├── milvus_demo.db # SQLite 元数据存储
│ ├── system_prompt.json # 系统提示词配置
│ └── requirements.txt # Python 依赖
│
├── web/ # Web 前端
│ ├── server.py # FastAPI 服务
│ │ ├── /api/config # 获取配置
│ │ ├── /api/favor/list # 宠物列表与好感度
│ │ ├── /api/favor/select # 切换宠物
│ │ └── /api/favor/reset # 重置设置
│ ├── index.html # 主页面
│ ├── components.js # 前端组件
│ ├── window_tool.py # Web 版工具
│ └── config/ # Web 配置
│
├── README.md
└── .gitignore
用户输入
│
▼
┌─────────────────────────────────────┐
│ 1. 检查是否包含图片 │
│ - 提取 <question>image:path</question>
│ - Base64 编码后发送到服务器 │
└─────────────────┬───────────────────┘
│
▼
┌─────────────────────────────────────┐
│ 2. 发送请求到 vLLM 服务器 │
│ POST /chat │
│ - question: 用户问题 │
│ - session_id: 会话标识 │
│ - character: 当前角色 Key │
│ - memory: 记忆上下文 │
│ - image: Base64 图片数据 │
└─────────────────┬───────────────────┘
│
▼
┌─────────────────────────────────────┐
│ 3. 解析流式响应 │
│ - <think> 思考过程 │
│ - <tool> 工具调用指令 │
│ - <observation> 工具返回结果 │
│ - <final answer> 最终回答 │
└─────────────────┬───────────────────┘
│
┌───────┴───────┐
▼ ▼
┌─────────────┐ ┌─────────────┐
│ 需要工具 │ │ 直接回答 │
│ 调用 │ │ │
└──────┬──────┘ └──────┬──────┘
▼ │
┌─────────────┐ │
│ WindowTool │ │
│ 执行工具 │ │
└──────┬──────┘ │
▼ │
└────────┬────────┘
▼
显示最终回答
宠物使用 XML 标签与后端通信,示例:
# 需要设置闹钟时
<tool>to_set_clock_alarm("06:30")</tool>
# 工具执行后返回
<observation>闹钟已设置为 06:30</observation>
# 最终回答
<final answer>已经为您设好闹钟了喵~ 记得准时起床哦!</final answer>
┌─────────────┐ 定时触发 ┌─────────────┐
│ 聊天记录 │ ────────────▶ │ LLM 摘要 │
│ (logs/*.txt)│ │ 提取爱好等 │
└─────────────┘ └──────┬──────┘
│
▼
┌─────────────┐
│ setting.ini │
│ [Memory] │
│ current_ │
│ memory │
└─────────────┘
[Url]
server_url = http://101.43.33.48:43351 # 远程 vLLM 服务器地址
[SessionID]
id = "user001" # 会话唯一标识
[General_Set]
current_index = 2 # 当前宠物索引 (1=六白, 2=七瑞)
[Nick_Name]
nickname1 = 六白 # 宠物昵称
nickname2 = 七瑞
[Memory]
current_memory = 主人:喜欢羽毛球;讨厌西红柿 # 记忆摘要
current_file = # 当前日志文件索引| Key | 说明 |
|---|---|
Character_1 |
猫娘角色:傲娇但内心温柔,银白毛发碧蓝瞳孔 |
Character_2 |
忠犬角色:敦厚柔软,黑色毛发金色瞳孔 |
Extra_Rule |
通用规则:工具调用格式、思考流程 |
New_Character_* |
Web 端简化角色定义 |
Summary_Prompt |
记忆摘要提取的提示词模板 |
- Python 3.8+
- Conda 环境(推荐)
- Windows 10/11(桌面应用)
- 网络可达远程服务器
# 激活 Conda 环境
conda activate local_pet
# 进入 src 目录
cd src
# 运行应用
python main.py# 进入 web 目录
cd web
# 安装依赖
pip install -r requirements.txt
# 运行服务
python server.py
# 访问 http://localhost:8000cd backend/rag-milvus-project
# 启动 vLLM(需提前部署)
python -m vllm.entrypoints.openai.api_server \
--model Qwen/Qwen3-30B-A3B-GPTQ-Int4 \
--host localhost --port 8001
# 启动 RAG 服务
python rag_server.pycd src
# 运行打包脚本(需在 Conda 环境)
python package.bat
# 打包产物位于 build/main.dist/main.exe打包配置:
--standalone: 独立打包,包含所有依赖--enable-plugin=pyside6: 启用 PySide6 插件--windows-console-mode=force: 保留控制台(调试用)--lto=yes: 链接时优化
PySide6>=6.5.0
requests>=2.28.0
pyautogui>=0.4.14
pygetwindow>=0.0.9
lunar-python>=1.15
chardet>=4.0.0
fastapi>=0.100.0
uvicorn>=0.23.0
langchain>=0.1.0
langchain-community>=0.0.10
langchain-openai>=0.0.2
langchain-huggingface>=0.0.1
langchain-milvus>=0.0.1
pymilvus>=2.3.0
huggingface-hub>=0.19.0
tavily-python>=0.3.0
fastapi>=0.100.0
uvicorn>=0.23.0
MIT License