mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 02:29:19 +08:00
fix: 收紧回答 harness 减少记忆场景啰嗦转述
This commit is contained in:
@@ -38,11 +38,11 @@ def memory_tools(svc: MemoryService, actor: Actor) -> list[BaseTool]:
|
||||
|
||||
@tool
|
||||
async def memory_search(query: str = "", limit: int = 8) -> str:
|
||||
"""搜索或列出当前用户的长期记忆摘要。
|
||||
"""搜索或列出当前用户的长期记忆摘要(结果仅供内部)。
|
||||
|
||||
query 可空:空则返回最近若干条。用户问「有哪些记忆 / 你记得我什么」时调用。
|
||||
返回 items: [{ref, summary, kind}];随后用 memory_load(refs) 取正文。
|
||||
向用户转述时只说摘要内容,禁止输出 ref、表格或内部字段。
|
||||
query 可空:空则返回最近若干条。用户问「有哪些记忆」时调用。
|
||||
返回 items: [{ref, summary, kind}];需要正文时再用 memory_load(refs)。
|
||||
对用户:只转述命中摘要,结论先行;不汇报未命中、多轮搜索或 ref。
|
||||
"""
|
||||
rows = await svc.search(actor, query or "", limit=limit)
|
||||
items = []
|
||||
@@ -65,9 +65,9 @@ def memory_tools(svc: MemoryService, actor: Actor) -> list[BaseTool]:
|
||||
|
||||
@tool
|
||||
async def memory_load(refs: list[int]) -> str:
|
||||
"""按 memory_search 返回的 ref 载入完整正文;单次最多 5 条。
|
||||
"""按 memory_search 的 ref 载入正文;单次最多 5 条(仅供内部)。
|
||||
|
||||
向用户转述时只叙述正文含义,禁止输出 ref 或内部字段。
|
||||
对用户只叙述正文含义,禁止输出 ref 或检索过程。
|
||||
"""
|
||||
ids: list[str] = []
|
||||
for r in refs or []:
|
||||
@@ -95,10 +95,9 @@ def memory_tools(svc: MemoryService, actor: Actor) -> list[BaseTool]:
|
||||
|
||||
@tool
|
||||
async def memory_save(text: str, kind: str = "fact") -> str:
|
||||
"""将用户明确要求记住的内容写入长期记忆(跨会话有效)。
|
||||
"""写入长期记忆(跨会话)。kind:preference / fact / entity。
|
||||
|
||||
用户说「记住…」时也可由系统自动写入;本工具用于你主动落库。
|
||||
kind 可选:preference / fact / entity。确认时只复述内容,不要提 ref/id。
|
||||
确认时只简短复述内容;不提 ref/id,不主动建议再记别的。
|
||||
"""
|
||||
kind_map = {
|
||||
"preference": MemoryKind.PREFERENCE,
|
||||
|
||||
Reference in New Issue
Block a user