mirror of
https://gitcode.com/JianFeeeee/TrulyMEM-TrueHumanMEM.git
synced 2026-09-21 17:38:18 +00:00
feat: 添加 context_rewrite 工具并清理工具限制器死配置
- 新增 context_rewrite 工具:允许 AI 在单轮内压缩工具调用上下文
- 清理 persona_query_max 和 task_query_max 死配置(commit 9be60ba 引入)
- 同步全栈:后端/前端/文档/测试 18 个文件
- 测试:70/70 通过
This commit is contained in:
10
ui/app.py
10
ui/app.py
@ -46,10 +46,8 @@ class GraphMemoryApp(App):
|
||||
initial_config.model = api_config.get("model", "deepseek-chat")
|
||||
|
||||
tool_limits = settings_data.get("tool_limits", {})
|
||||
initial_config.persona_query_max = tool_limits.get("persona_query_max", 1)
|
||||
initial_config.persona_update_max = tool_limits.get("persona_update_max", 1)
|
||||
initial_config.task_query_max = tool_limits.get("task_query_max", 4)
|
||||
initial_config.task_update_max = tool_limits.get("task_update_max", 2)
|
||||
initial_config.task_update_max = tool_limits.get("task_update_max", 5)
|
||||
initial_config.memory_query_max = tool_limits.get("memory_query_max", 20)
|
||||
initial_config.memory_update_max = tool_limits.get("memory_update_max", 10)
|
||||
|
||||
@ -222,9 +220,7 @@ class GraphMemoryApp(App):
|
||||
}
|
||||
|
||||
tool_limits = {
|
||||
"persona_query_max": config.persona_query_max,
|
||||
"persona_update_max": config.persona_update_max,
|
||||
"task_query_max": config.task_query_max,
|
||||
"task_update_max": config.task_update_max,
|
||||
"memory_query_max": config.memory_query_max,
|
||||
"memory_update_max": config.memory_update_max,
|
||||
@ -257,10 +253,8 @@ class GraphMemoryApp(App):
|
||||
api_key=api_cfg.get("api_key", ""),
|
||||
base_url=api_cfg.get("base_url", "https://api.deepseek.com"),
|
||||
model=api_cfg.get("model", "deepseek-chat"),
|
||||
persona_query_max=tool_lmts.get("persona_query_max", 1),
|
||||
persona_update_max=tool_lmts.get("persona_update_max", 1),
|
||||
task_query_max=tool_lmts.get("task_query_max", 4),
|
||||
task_update_max=tool_lmts.get("task_update_max", 2),
|
||||
task_update_max=tool_lmts.get("task_update_max", 5),
|
||||
memory_query_max=tool_lmts.get("memory_query_max", 20),
|
||||
memory_update_max=tool_lmts.get("memory_update_max", 10),
|
||||
))
|
||||
|
||||
@ -13,10 +13,8 @@ class AppConfig:
|
||||
api_key: str = ""
|
||||
model: str = "deepseek-chat"
|
||||
base_url: str = "https://api.deepseek.com"
|
||||
persona_query_max: int = 1
|
||||
persona_update_max: int = 1
|
||||
task_query_max: int = 4
|
||||
task_update_max: int = 2
|
||||
task_update_max: int = 5
|
||||
memory_query_max: int = 20
|
||||
memory_update_max: int = 10
|
||||
|
||||
@ -26,10 +24,8 @@ class AppConfig:
|
||||
api_key=os.getenv("DEEPSEEK_API_KEY", ""),
|
||||
model=os.getenv("MODEL_NAME", "deepseek-chat"),
|
||||
base_url=os.getenv("DEEPSEEK_BASE_URL", "https://api.deepseek.com"),
|
||||
persona_query_max=int(os.getenv("PERSONA_QUERY_MAX", 1)),
|
||||
persona_update_max=int(os.getenv("PERSONA_UPDATE_MAX", 1)),
|
||||
task_query_max=int(os.getenv("TASK_QUERY_MAX", 4)),
|
||||
task_update_max=int(os.getenv("TASK_UPDATE_MAX", 2)),
|
||||
task_update_max=int(os.getenv("TASK_UPDATE_MAX", 5)),
|
||||
memory_query_max=int(os.getenv("MEMORY_QUERY_MAX", 20)),
|
||||
memory_update_max=int(os.getenv("MEMORY_UPDATE_MAX", 10)),
|
||||
)
|
||||
@ -46,10 +42,8 @@ class AppConfig:
|
||||
api_key=data.get("api_key", ""),
|
||||
model=data.get("model", "deepseek-chat"),
|
||||
base_url=data.get("base_url", "https://api.deepseek.com"),
|
||||
persona_query_max=data.get("persona_query_max", 1),
|
||||
persona_update_max=data.get("persona_update_max", 1),
|
||||
task_query_max=data.get("task_query_max", 4),
|
||||
task_update_max=data.get("task_update_max", 2),
|
||||
task_update_max=data.get("task_update_max", 5),
|
||||
memory_query_max=data.get("memory_query_max", 20),
|
||||
memory_update_max=data.get("memory_update_max", 10),
|
||||
)
|
||||
|
||||
@ -63,25 +63,15 @@ class ConfigSection(Vertical):
|
||||
limits_title.can_focus = False
|
||||
yield limits_title
|
||||
|
||||
l1 = Static("人设图查询:", classes="config-label")
|
||||
l1.can_focus = False
|
||||
yield l1
|
||||
yield Input(value=str(self._config.persona_query_max), placeholder="1", id="persona-query-max")
|
||||
|
||||
l2 = Static("人设图修改:", classes="config-label")
|
||||
l2.can_focus = False
|
||||
yield l2
|
||||
yield Input(value=str(self._config.persona_update_max), placeholder="1", id="persona-update-max")
|
||||
|
||||
l3 = Static("工作记忆查询:", classes="config-label")
|
||||
l3.can_focus = False
|
||||
yield l3
|
||||
yield Input(value=str(self._config.task_query_max), placeholder="4", id="task-query-max")
|
||||
|
||||
l4 = Static("工作记忆修改:", classes="config-label")
|
||||
l4.can_focus = False
|
||||
yield l4
|
||||
yield Input(value=str(self._config.task_update_max), placeholder="2", id="task-update-max")
|
||||
yield Input(value=str(self._config.task_update_max), placeholder="5", id="task-update-max")
|
||||
|
||||
l5 = Static("一般记忆查询:", classes="config-label")
|
||||
l5.can_focus = False
|
||||
@ -122,9 +112,7 @@ class ConfigSection(Vertical):
|
||||
model_input = self.query_one("#model-input", Input)
|
||||
base_url_input = self.query_one("#base-url-input", Input)
|
||||
|
||||
persona_query = self.query_one("#persona-query-max", Input)
|
||||
persona_update = self.query_one("#persona-update-max", Input)
|
||||
task_query = self.query_one("#task-query-max", Input)
|
||||
task_update = self.query_one("#task-update-max", Input)
|
||||
memory_query = self.query_one("#memory-query-max", Input)
|
||||
memory_update = self.query_one("#memory-update-max", Input)
|
||||
@ -133,10 +121,8 @@ class ConfigSection(Vertical):
|
||||
api_key=api_key_input.value,
|
||||
model=model_input.value,
|
||||
base_url=base_url_input.value,
|
||||
persona_query_max=int(persona_query.value or 1),
|
||||
persona_update_max=int(persona_update.value or 1),
|
||||
task_query_max=int(task_query.value or 4),
|
||||
task_update_max=int(task_update.value or 2),
|
||||
task_update_max=int(task_update.value or 5),
|
||||
memory_query_max=int(memory_query.value or 20),
|
||||
memory_update_max=int(memory_update.value or 10),
|
||||
)
|
||||
@ -162,9 +148,7 @@ class ConfigSection(Vertical):
|
||||
model_input.value = config.model
|
||||
base_url_input.value = config.base_url
|
||||
|
||||
self.query_one("#persona-query-max", Input).value = str(config.persona_query_max)
|
||||
self.query_one("#persona-update-max", Input).value = str(config.persona_update_max)
|
||||
self.query_one("#task-query-max", Input).value = str(config.task_query_max)
|
||||
self.query_one("#task-update-max", Input).value = str(config.task_update_max)
|
||||
self.query_one("#memory-query-max", Input).value = str(config.memory_query_max)
|
||||
self.query_one("#memory-update-max", Input).value = str(config.memory_update_max)
|
||||
|
||||
Reference in New Issue
Block a user