From 558eee4f58c31ff53b5694e8b881d50b63cdaa4f Mon Sep 17 00:00:00 2001 From: root Date: Tue, 14 Apr 2026 16:28:17 +0800 Subject: [PATCH] docs: fix garbled text, sync architecture with code, add tool limits API --- docs/en/api.md | 68 ++++++++++++++++++++++++++++++++++++++++- docs/en/architecture.md | 9 +++--- docs/zh/api.md | 68 ++++++++++++++++++++++++++++++++++++++++- docs/zh/architecture.md | 9 +++--- docs/zh/memory.md | 2 +- 5 files changed, 143 insertions(+), 13 deletions(-) diff --git a/docs/en/api.md b/docs/en/api.md index 117bd25..d098fe8 100644 --- a/docs/en/api.md +++ b/docs/en/api.md @@ -27,6 +27,8 @@ class PacketType(Enum): GET_STATUS = "get_status" # Get status GET_CONFIG = "get_config" # Get config SET_CONFIG = "set_config" # Set config + GET_TOOL_LIMITS = "get_tool_limits" # Get tool limits + SET_TOOL_LIMITS = "set_tool_limits" # Set tool limits GET_HISTORY = "get_history" # Get history SAVE_HISTORY = "save_history" # Save history SHUTDOWN = "shutdown" # Shutdown service @@ -199,7 +201,71 @@ body = { --- -### 6. GET_HISTORY - Get Message History +### 6. GET_TOOL_LIMITS - Get Tool Limits + +Get current AI reasoning tool call limits. + +**Request Parameters:** +```python +body = {} # No parameters +``` + +**Response Data:** +```python +{ + "persona_query_max": int, # Persona graph query limit + "persona_update_max": int, # Persona graph update limit + "task_query_max": int, # Working memory query limit + "task_update_max": int, # Working memory update limit + "memory_query_max": int, # General memory query limit + "memory_update_max": int # General memory update limit +} +``` + +**Example:** +```python +result = client.get_tool_limits() +print(result["data"]["persona_query_max"]) # 1 +``` + +--- + +### 7. SET_TOOL_LIMITS - Set Tool Limits + +Set AI reasoning tool call limits. + +**Request Parameters:** +```python +body = { + "persona_query_max": int, # Persona query limit (≥1) + "persona_update_max": int, # Persona update limit (≥1) + "task_query_max": int, # Working memory query limit (≥1) + "task_update_max": int, # Working memory update limit (≥1) + "memory_query_max": int, # General memory query limit (≥1) + "memory_update_max": int # General memory update limit (≥1) +} +``` + +**Response Data:** +```python +{ + "status": "tool_limits_updated", + "limits": {...} # Updated limits +} +``` + +**Example:** +```python +result = client.update_tool_limits( + persona_query_max=2, + task_query_max=5, + memory_query_max=30 +) +``` + +--- + +### 8. GET_HISTORY - Get Message History Get saved message history. diff --git a/docs/en/architecture.md b/docs/en/architecture.md index ba22f46..67c5e51 100644 --- a/docs/en/architecture.md +++ b/docs/en/architecture.md @@ -17,21 +17,20 @@ TrulyMEM-TrueHumanMEM/ │ ├── __init__.py # Export BackendServer, BackendClient, EmbeddedGraphDB │ ├── server.py # BackendServer (Packet communication protocol) │ ├── client.py # BackendClient (Packet protocol client) -│ ├── embedded_db.py # SQLite graph database implementation +│ ├── embedded_db.py # SQLite graph database implementation │ ├── graph_client.py # OpenAI/DeepSeek API client │ ├── tool_executor.py # Tool executor -│ ├── tool_limiter.py # Tool call limiter +│ ├── tool_limiter.py # Tool call limiter │ ├── tools/ # Tool definitions -│ │ ├── __init__.py │ │ └── memory_tools.py │ └── prompts/ # Prompt management ├── ui/ # TUI display layer (display only, no AI logic) -│ ├── __init__.py # Export GraphMemoryApp, AppConfig +│ ├── __init__.py # Export GraphMemoryApp │ ├── app.py # GraphMemoryApp (communicates via BackendClient) │ ├── widgets/ # TUI components -│ ├── handlers/ # Event handlers │ ├── models/ # Data models │ ├── services/ # Service layer (config only) +│ ├── handlers/ # Event handlers │ └── styles/ # Style files └── tests/ # Tests (42 tests) ``` diff --git a/docs/zh/api.md b/docs/zh/api.md index 41dd4c8..c9b426e 100644 --- a/docs/zh/api.md +++ b/docs/zh/api.md @@ -27,6 +27,8 @@ class PacketType(Enum): GET_STATUS = "get_status" # 获取状态 GET_CONFIG = "get_config" # 获取配置 SET_CONFIG = "set_config" # 设置配置 + GET_TOOL_LIMITS = "get_tool_limits" # 获取工具限制 + SET_TOOL_LIMITS = "set_tool_limits" # 设置工具限制 GET_HISTORY = "get_history" # 获取历史 SAVE_HISTORY = "save_history" # 保存历史 SHUTDOWN = "shutdown" # 关闭服务 @@ -214,7 +216,71 @@ result = client.update_config( --- -### 6. GET_HISTORY - 获取消息历史 +### 6. GET_TOOL_LIMITS - 获取工具限制 + +获取当前 AI 推理时的工具调用限制配置。 + +**请求参数:** +```python +body = {} # 无参数 +``` + +**响应数据:** +```python +{ + "persona_query_max": int, # 人设图查询上限 + "persona_update_max": int, # 人设图修改上限 + "task_query_max": int, # 工作记忆查询上限 + "task_update_max": int, # 工作记忆修改上限 + "memory_query_max": int, # 一般记忆查询上限 + "memory_update_max": int # 一般记忆修改上限 +} +``` + +**示例:** +```python +result = client.get_tool_limits() +print(result["data"]["persona_query_max"]) # 1 +``` + +--- + +### 7. SET_TOOL_LIMITS - 设置工具限制 + +设置 AI 推理时的工具调用限制。 + +**请求参数:** +```python +body = { + "persona_query_max": int, # 人设图查询上限 (≥1) + "persona_update_max": int, # 人设图修改上限 (≥1) + "task_query_max": int, # 工作记忆查询上限 (≥1) + "task_update_max": int, # 工作记忆修改上限 (≥1) + "memory_query_max": int, # 一般记忆查询上限 (≥1) + "memory_update_max": int # 一般记忆修改上限 (≥1) +} +``` + +**响应数据:** +```python +{ + "status": "tool_limits_updated", + "limits": {...} # 更新后的限制 +} +``` + +**示例:** +```python +result = client.update_tool_limits( + persona_query_max=2, + task_query_max=5, + memory_query_max=30 +) +``` + +--- + +### 8. GET_HISTORY - 获取消息历史 获取保存的消息历史。 diff --git a/docs/zh/architecture.md b/docs/zh/architecture.md index 0304c66..8351876 100644 --- a/docs/zh/architecture.md +++ b/docs/zh/architecture.md @@ -17,21 +17,20 @@ TrulyMEM-TrueHumanMEM/ │ ├── __init__.py # 导出 BackendServer, BackendClient, EmbeddedGraphDB │ ├── server.py # BackendServer (Packet 通信协议) │ ├── client.py # BackendClient (Packet 协议客户端) -│ ├── embedded_db.py # SQLite 图数据库实现 +│ ├── embedded_db.py # SQLite 图数据库实现 │ ├── graph_client.py # OpenAI/DeepSeek API 客户端 │ ├── tool_executor.py # 工具执行器 -│ ├── tool_limiter.py # 工具调用限制器 +│ ├── tool_limiter.py # 工具调用限制器 │ ├── tools/ # 工具定义 -│ │ ├── __init__.py │ │ └── memory_tools.py │ └── prompts/ # 提示词管理 ├── ui/ # TUI 显示层(仅显示,无 AI 逻辑) -│ ├── __init__.py # 导出 GraphMemoryApp, AppConfig +│ ├── __init__.py # 导出 GraphMemoryApp │ ├── app.py # GraphMemoryApp (通过 BackendClient 通信) │ ├── widgets/ # TUI 组件 -│ ├── handlers/ # 事件处理 │ ├── models/ # 数据模型 │ ├── services/ # 服务层(仅配置管理) +│ ├── handlers/ # 事件处理 │ └── styles/ # 样式文件 └── tests/ # 测试 (42 tests) ``` diff --git a/docs/zh/memory.md b/docs/zh/memory.md index cb92874..00343ca 100644 --- a/docs/zh/memory.md +++ b/docs/zh/memory.md @@ -133,7 +133,7 @@ task_create( --- -## 必须查���工作记忆链的场景 +## 必须查询工作记忆链的场景 ### 强制查询场景