docs: 修正文档与代码实现一致,添加 model 参数描述,区分源码/打包运行模式

This commit is contained in:
root
2026-04-14 12:00:57 +08:00
parent 4e9f533c93
commit f26b3d8951
3 changed files with 34 additions and 10 deletions

View File

@ -99,7 +99,7 @@ TrulyMEM-TrueHumanMEM/
│ ├── app.py # 主应用 │ ├── app.py # 主应用
│ ├── widgets/ # UI 组件 │ ├── widgets/ # UI 组件
│ └── models/ # 数据模型 │ └── models/ # 数据模型
└── tests/ # 测试 (37 tests) └── tests/ # 测试 (42 tests)
``` ```
### 启动流程 ### 启动流程
@ -172,7 +172,7 @@ result = client.process_message("hello")
pytest tests/ pytest tests/
``` ```
37 个测试用例覆盖: 42 个测试用例覆盖:
- 数据包协议 - 数据包协议
- 后端初始化/启动/关闭 - 后端初始化/启动/关闭
- 客户端方法 - 客户端方法

View File

@ -191,7 +191,8 @@ body = {} # 无参数
```python ```python
body = { body = {
"api_key": str, # API Key "api_key": str, # API Key
"base_url": str # API Base URL (默认: https://api.deepseek.com) "base_url": str, # API Base URL (默认: https://api.deepseek.com)
"model": str # 模型名称 (默认: deepseek-chat)
} }
``` ```
@ -206,7 +207,8 @@ body = {
```python ```python
result = client.update_config( result = client.update_config(
api_key="sk-xxxxx", api_key="sk-xxxxx",
base_url="https://api.deepseek.com" base_url="https://api.deepseek.com",
model="deepseek-chat"
) )
``` ```
@ -276,15 +278,25 @@ body = {} # 无参数
from core import BackendServer, BackendClient from core import BackendServer, BackendClient
# 1. 创建并启动后端 # 1. 创建并启动后端
server = BackendServer(db_path="graph_memory.db", use_embedded_db=True) # config_file 默认: ~/.trulymem/config.json
server.start(api_key="your-api-key", base_url="https://api.deepseek.com") server = BackendServer(
db_path="graph_memory.db",
use_embedded_db=True,
config_file=None # 可选,自定义配置路径
)
server.start(
api_key="your-api-key",
base_url="https://api.deepseek.com",
model="deepseek-chat" # 可选,模型名称
)
# 2. 创建客户端 # 2. 创建客户端
client = BackendClient(server) client = BackendClient(server)
# 3. 发送消息 # 3. 发送消息
result = client.process_message("你好") result = client.process_message("你好")
print(result["content"]) if result.get("success"):
print(result["content"])
# 4. 关闭 # 4. 关闭
client.shutdown() client.shutdown()
@ -296,8 +308,8 @@ client.shutdown()
import queue import queue
from core import BackendServer, Packet, PacketType from core import BackendServer, Packet, PacketType
server = BackendServer() server = BackendServer(config_file=None)
server.start(api_key="your-key") server.start(api_key="your-key", model="deepseek-chat")
# 创建请求包 # 创建请求包
response_queue = queue.Queue() response_queue = queue.Queue()

View File

@ -52,12 +52,24 @@ TrulyMEM.exe
## 数据存储 ## 数据存储
### 源码运行模式
| 数据 | 位置 | | 数据 | 位置 |
|------|------| |------|------|
| 图数据库 | `graph_memory.db`(应用目录) | | 图数据库 | 项目目录 `graph_memory.db` |
| 配置文件 | 项目目录 `config.json`(如存在) |
| 数据库格式 | SQLite |
### 打包运行模式
| 数据 | 位置 |
|------|------|
| 图数据库 | `~/.trulymem/graph_memory.db` |
| 配置文件 | `~/.trulymem/config.json` | | 配置文件 | `~/.trulymem/config.json` |
| 数据库格式 | SQLite | | 数据库格式 | SQLite |
> **说明**:后端统一管理配置。前端仅负责消息展示,配置修改通过后端持久化到文件系统。
## 架构说明 ## 架构说明
### 通信协议 ### 通信协议