fix: memory recall fuction prompt

This commit is contained in:
0Xiao0
2026-05-14 11:18:04 +08:00
parent 3a2f5c4252
commit 89011fed81
2 changed files with 14 additions and 7 deletions

View File

@ -36,10 +36,19 @@ CUSTOM_ENV_PATH = Path(__file__).with_name(".env")
load_dotenv(dotenv_path=CUSTOM_ENV_PATH) load_dotenv(dotenv_path=CUSTOM_ENV_PATH)
AGENT_NAME = os.getenv("CUSTOM_AGENT_NAME", "") AGENT_NAME = os.getenv("CUSTOM_AGENT_NAME", "")
ROOM_LOCATOR_INSTRUCTIONS = """
你是一个房间物品定位助手。
当用户询问房间内某个物品的位置时:
- 只用一句中文回答
- 描述目标物品和其他物品的相对位置关系
- 不要使用 Markdown、emoji、列表、标题、坐标区域标签
- 不要解释推理过程
如果用户的问题与房间物品定位无关,则正常回答用户问题。
""".strip()
class CustomAgent(Agent): class CustomAgent(Agent):
def __init__(self, *, memory_client: MemoryRecallClient | None = None) -> None: def __init__(self, *, memory_client: MemoryRecallClient | None = None) -> None:
super().__init__(instructions="") super().__init__(instructions=ROOM_LOCATOR_INSTRUCTIONS)
self._memory_client = memory_client self._memory_client = memory_client
async def on_enter(self) -> None: async def on_enter(self) -> None:

View File

@ -96,7 +96,6 @@ def _format_room_graph_memory(payload: Any, query: str) -> str:
objects = payload.get("objects", []) objects = payload.get("objects", [])
relations = payload.get("relations", []) relations = payload.get("relations", [])
summary = payload.get("summary", "") summary = payload.get("summary", "")
usage_hint = payload.get("usage_hint", "")
if not objects and not relations and not summary: if not objects and not relations and not summary:
return "" return ""
@ -128,10 +127,9 @@ def _format_room_graph_memory(payload: Any, query: str) -> str:
2. 不要编造不存在的关系。 2. 不要编造不存在的关系。
3. 如果信息不足,请说“根据当前房间记忆,无法确定准确位置”。 3. 如果信息不足,请说“根据当前房间记忆,无法确定准确位置”。
4. 回答尽量简短,例如:“黑色背包在透明塑料盒的左边,在显示器的左边。” 4. 回答尽量简短,例如:“黑色背包在透明塑料盒的左边,在显示器的左边。”
5. 如果用户当前输入不是找物品或问位置,可以忽略这段房间记忆 5. 不要输出 Markdown、emoji、标题、列表、项目符号、坐标区域标签、水平/深度/高度分析或解释过程
6. 不要回答 right-near-low、left-far-high 这类区域标签,只回答“在……的左边/右边/上方/下方/前面/后面/附近”等相对关系。
7. 如果用户当前输入不是找物品或问位置,可以忽略这段房间记忆。
""".strip() """.strip()
if usage_hint:
prompt += f"\n\n接口使用提示:\n{usage_hint}"
return prompt return prompt