Merge branch 'refs/heads/fix/memory_mcp2_1' into develop

# Conflicts:
#	api/app/core/memory/agent/langgraph_graph/nodes/problem_nodes.py
#	api/app/core/memory/agent/langgraph_graph/nodes/summary_nodes.py
#	api/app/core/memory/agent/langgraph_graph/nodes/verification_nodes.py
#	api/app/core/memory/agent/langgraph_graph/read_graph.py
#	api/app/core/memory/agent/langgraph_graph/routing/routers.py
#	api/app/core/memory/agent/models/verification_models.py
#	api/app/core/memory/agent/services/optimized_llm_service.py
This commit is contained in:
lixinyue
2026-01-21 11:45:17 +08:00
3 changed files with 5 additions and 17 deletions

View File

@@ -1,4 +1,3 @@
import os
import json
import time
from app.core.logging_config import get_agent_logger
@@ -14,7 +13,7 @@ from app.core.memory.agent.utils.session_tools import SessionService
from app.core.memory.agent.utils.template_tools import TemplateService
from app.core.memory.agent.services.optimized_llm_service import LLMServiceMixin
template_root = os.path.join(PROJECT_ROOT_, 'agent', 'utils', 'prompt')
template_root = PROJECT_ROOT_ + '/agent/utils/prompt'
db_session = next(get_db())
logger = get_agent_logger(__name__)
@@ -36,16 +35,11 @@ async def Split_The_Problem(state: ReadState) -> ReadState:
memory_config = state.get('memory_config', None)
history = await SessionService(store).get_history(group_id, group_id, group_id)
# 生成 JSON schema 以指导 LLM 输出正确格式
json_schema = ProblemExtensionResponse.model_json_schema()
system_prompt = await problem_service.template_service.render_template(
template_name='problem_breakdown_prompt.jinja2',
operation_name='split_the_problem',
history=history,
sentence=content,
json_schema=json_schema
sentence=content
)
try:
@@ -153,16 +147,11 @@ async def Problem_Extension(state: ReadState) -> ReadState:
data = []
history = await SessionService(store).get_history(group_id, group_id, group_id)
# 生成 JSON schema 以指导 LLM 输出正确格式
json_schema = ProblemExtensionResponse.model_json_schema()
system_prompt = await problem_service.template_service.render_template(
template_name='Problem_Extension_prompt.jinja2',
operation_name='problem_extension',
history=history,
questions=databasets,
json_schema=json_schema
questions=databasets
)
try:

View File

@@ -59,7 +59,6 @@ async def make_read_graph():
workflow.add_conditional_edges("Retrieve", Retrieve_continue)
workflow.add_edge("Retrieve_Summary", END)
workflow.add_conditional_edges("Verify", Verify_continue)
workflow.add_edge("Summary_fails", END)
workflow.add_edge("Summary", END)

View File

@@ -162,7 +162,7 @@ class OptimizedLLMService:
return fallback_value
elif isinstance(fallback_value, dict):
return response_model(**fallback_value)
# 尝试创建空的响应模型
if hasattr(response_model, 'root'):
# RootModel类型
@@ -170,7 +170,7 @@ class OptimizedLLMService:
else:
# 普通BaseModel类型
return response_model()
except Exception as e:
logger.error(f"创建降级响应失败: {e}")
# 最后的降级策略