Fix/develop memory bug (#276)
* 遗漏的历史映射 * 遗漏的历史映射 * fix_timeline_memories * fix_timeline_memories * write_gragp/bug_fix * write_gragp/bug_fix * write_gragp/bug_fix
This commit is contained in:
@@ -39,7 +39,6 @@ async def make_write_graph():
|
|||||||
graph = workflow.compile()
|
graph = workflow.compile()
|
||||||
|
|
||||||
yield graph
|
yield graph
|
||||||
|
|
||||||
async def long_term_storage(long_term_type:str="chunk",langchain_messages:list=[],memory_config:str='',end_user_id:str='',scope:int=6):
|
async def long_term_storage(long_term_type:str="chunk",langchain_messages:list=[],memory_config:str='',end_user_id:str='',scope:int=6):
|
||||||
from app.core.memory.agent.langgraph_graph.routing.write_router import memory_long_term_storage, window_dialogue,aggregate_judgment
|
from app.core.memory.agent.langgraph_graph.routing.write_router import memory_long_term_storage, window_dialogue,aggregate_judgment
|
||||||
from app.core.memory.agent.langgraph_graph.tools.write_tool import chat_data_format
|
from app.core.memory.agent.langgraph_graph.tools.write_tool import chat_data_format
|
||||||
@@ -49,7 +48,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':
|
||||||
@@ -63,7 +62,7 @@ async def long_term_storage(long_term_type:str="chunk",langchain_messages:list=[
|
|||||||
"""方案三:聚合判断"""
|
"""方案三:聚合判断"""
|
||||||
await aggregate_judgment(end_user_id, langchain_messages, memory_config)
|
await aggregate_judgment(end_user_id, langchain_messages, memory_config)
|
||||||
|
|
||||||
#
|
|
||||||
# async def main():
|
# async def main():
|
||||||
# """主函数 - 运行工作流"""
|
# """主函数 - 运行工作流"""
|
||||||
# langchain_messages = [
|
# langchain_messages = [
|
||||||
@@ -80,14 +79,7 @@ async def long_term_storage(long_term_type:str="chunk",langchain_messages:list=[
|
|||||||
# end_user_id = '837fee1b-04a2-48ee-94d7-211488908940' # 组ID
|
# end_user_id = '837fee1b-04a2-48ee-94d7-211488908940' # 组ID
|
||||||
# memory_config="08ed205c-0f05-49c3-8e0c-a580d28f5fd4"
|
# memory_config="08ed205c-0f05-49c3-8e0c-a580d28f5fd4"
|
||||||
# # await long_term_storage(long_term_type="chunk",langchain_messages=langchain_messages,memory_config=memory_config,end_user_id=end_user_id,scope=2)
|
# # await long_term_storage(long_term_type="chunk",langchain_messages=langchain_messages,memory_config=memory_config,end_user_id=end_user_id,scope=2)
|
||||||
# from app.core.memory.agent.utils.redis_tool import write_store
|
# result=await long_term_storage(long_term_type="chunk",langchain_messages=langchain_messages,memory_config=memory_config,end_user_id=end_user_id,scope=2)
|
||||||
# result=write_store.get_session_by_userid(end_user_id)
|
|
||||||
# data=await format_parsing(result,"dict")
|
|
||||||
# chunk_data=data[:6]
|
|
||||||
#
|
|
||||||
# long_time_data = write_store.find_user_recent_sessions(end_user_id, 240)
|
|
||||||
# long_=await messages_parse(long_time_data)
|
|
||||||
# print(long_)
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# if __name__ == "__main__":
|
# if __name__ == "__main__":
|
||||||
|
|||||||
@@ -377,7 +377,6 @@ class MemoryReflectionService:
|
|||||||
iteration_period = int(iteration_period)
|
iteration_period = int(iteration_period)
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
iteration_period = 24 # 默认24小时
|
iteration_period = 24 # 默认24小时
|
||||||
|
|
||||||
return ReflectionConfig(
|
return ReflectionConfig(
|
||||||
enabled=config_data.get("enable_self_reflexion", False),
|
enabled=config_data.get("enable_self_reflexion", False),
|
||||||
iteration_period=str(iteration_period), # ReflectionConfig期望字符串
|
iteration_period=str(iteration_period), # ReflectionConfig期望字符串
|
||||||
|
|||||||
Reference in New Issue
Block a user