memory_BUG_fix
This commit is contained in:
@@ -49,7 +49,7 @@ async def long_term_storage(long_term_type:str="chunk",langchain_messages:list=[
|
|||||||
db_session = next(get_db())
|
db_session = next(get_db())
|
||||||
config_service = MemoryConfigService(db_session)
|
config_service = MemoryConfigService(db_session)
|
||||||
memory_config = config_service.load_memory_config(
|
memory_config = config_service.load_memory_config(
|
||||||
config_id="08ed205c-0f05-49c3-8e0c-a580d28f5fd4", # 改为整数
|
config_id=memory_config, # 改为整数
|
||||||
service_name="MemoryAgentService"
|
service_name="MemoryAgentService"
|
||||||
)
|
)
|
||||||
if long_term_type=='chunk':
|
if long_term_type=='chunk':
|
||||||
@@ -59,7 +59,6 @@ async def long_term_storage(long_term_type:str="chunk",langchain_messages:list=[
|
|||||||
"""时间"""
|
"""时间"""
|
||||||
await memory_long_term_storage(end_user_id, memory_config,5)
|
await memory_long_term_storage(end_user_id, memory_config,5)
|
||||||
if long_term_type=='aggregate':
|
if long_term_type=='aggregate':
|
||||||
|
|
||||||
"""方案三:聚合判断"""
|
"""方案三:聚合判断"""
|
||||||
await aggregate_judgment(end_user_id, langchain_messages, memory_config)
|
await aggregate_judgment(end_user_id, langchain_messages, memory_config)
|
||||||
|
|
||||||
|
|||||||
@@ -110,6 +110,8 @@ def create_long_term_memory_tool(memory_config: Dict[str, Any], end_user_id: str
|
|||||||
result = task_service.get_task_memory_read_result(task.id)
|
result = task_service.get_task_memory_read_result(task.id)
|
||||||
status = result.get("status")
|
status = result.get("status")
|
||||||
logger.info(f"读取任务状态:{status}")
|
logger.info(f"读取任务状态:{status}")
|
||||||
|
if memory_content:
|
||||||
|
memory_content = memory_content['answer']
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
db.close()
|
db.close()
|
||||||
@@ -123,7 +125,6 @@ def create_long_term_memory_tool(memory_config: Dict[str, Any], end_user_id: str
|
|||||||
"content_length": len(str(memory_content))
|
"content_length": len(str(memory_content))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
return f"检索到以下历史记忆:\n\n{memory_content}"
|
return f"检索到以下历史记忆:\n\n{memory_content}"
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("长期记忆检索失败", extra={"error": str(e), "error_type": type(e).__name__})
|
logger.error("长期记忆检索失败", extra={"error": str(e), "error_type": type(e).__name__})
|
||||||
|
|||||||
Reference in New Issue
Block a user