This commit is contained in:
@@ -184,4 +184,4 @@ def create_llm_call_node(llm, tools: list):
|
||||
log_state_change("llm_call", state, "离开(异常)")
|
||||
return error_result
|
||||
|
||||
return call_llm
|
||||
return call_llm
|
||||
@@ -17,6 +17,7 @@ from app.main_graph.utils.retry_utils import (
|
||||
RAG_RETRY_CONFIG,
|
||||
create_retry_wrapper_for_node
|
||||
)
|
||||
from app.logger import info
|
||||
|
||||
# 真正导入和利用已有 RAG 代码
|
||||
from app.rag.tools import create_rag_tool
|
||||
@@ -95,7 +96,7 @@ def inject_rag_tool_to_state(state: MainGraphState, rag_tool: Any) -> MainGraphS
|
||||
return state
|
||||
|
||||
|
||||
# ========== RAG 检索核心逻辑(真正利用已有代码) ==========
|
||||
# ========== RAG 检索核心逻辑(真正利用已有代码)==========
|
||||
async def _rag_retrieve_core(state: MainGraphState) -> MainGraphState:
|
||||
"""
|
||||
RAG 检索核心逻辑(真正利用 rag/tools.py) - 异步版本
|
||||
@@ -158,7 +159,7 @@ async def _rag_retrieve_core(state: MainGraphState) -> MainGraphState:
|
||||
raise RuntimeError("RAG 工具未初始化,请先调用 set_global_rag_tool() 或 set_global_rag_pipeline()")
|
||||
|
||||
|
||||
# ========== RAG 检索节点(带超时和重试) ==========
|
||||
# ========== RAG 检索节点(带超时和重试)==========
|
||||
async def rag_retrieve_node(state: MainGraphState, config: Optional[Dict[str, Any]] = None) -> MainGraphState:
|
||||
"""
|
||||
RAG 检索节点:带超时和重试,真正利用已有 RAG 代码
|
||||
|
||||
@@ -44,9 +44,6 @@ class ErrorRecord:
|
||||
@dataclass
|
||||
class MainGraphState:
|
||||
"""
|
||||
主图状态 - 整合了旧 MessagesState 的所有字段
|
||||
|
||||
包含:
|
||||
- 旧代码的 MessagesState 兼容性字段
|
||||
- React 推理控制字段
|
||||
- 循环和错误处理
|
||||
@@ -69,7 +66,7 @@ class MainGraphState:
|
||||
|
||||
# ========== React 推理专用字段 ==========
|
||||
reasoning_step: int = 0
|
||||
max_steps: int = 40
|
||||
max_steps: int = 10 # 从 40 改到 10,避免过长循环
|
||||
last_action: str = ""
|
||||
reasoning_history: List[Dict[str, Any]] = field(default_factory=list)
|
||||
|
||||
|
||||
@@ -2,21 +2,12 @@
|
||||
"""
|
||||
快速测试 - 测试 fast_rag 路径修复
|
||||
"""
|
||||
import sys
|
||||
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# 路径设置
|
||||
project_root = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(project_root))
|
||||
sys.path.insert(0, str(project_root / "backend"))
|
||||
load_dotenv(project_root / ".env")
|
||||
|
||||
from app.main_graph.state import MainGraphState, CurrentAction
|
||||
from app.main_graph.utils.main_graph_builder import build_react_main_graph
|
||||
from app.model_services.chat_services import get_all_chat_services
|
||||
from app.main_graph.tools.graph_tools import AVAILABLE_TOOLS
|
||||
from backend.app.main_graph.state import MainGraphState, CurrentAction
|
||||
from backend.app.main_graph.utils.main_graph_builder import build_react_main_graph
|
||||
from backend.app.model_services.chat_services import get_all_chat_services
|
||||
from backend.app.main_graph.tools.graph_tools import AVAILABLE_TOOLS
|
||||
|
||||
|
||||
async def test_fast_rag_path():
|
||||
|
||||
@@ -7,17 +7,12 @@ import asyncio
|
||||
from pathlib import Path
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# 路径设置
|
||||
project_root = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(project_root))
|
||||
sys.path.insert(0, str(project_root / "backend"))
|
||||
load_dotenv(project_root / ".env")
|
||||
|
||||
from app.main_graph.state import MainGraphState, CurrentAction
|
||||
from app.main_graph.utils.main_graph_builder import build_react_main_graph
|
||||
from app.model_services.chat_services import get_all_chat_services
|
||||
from app.main_graph.tools.graph_tools import AVAILABLE_TOOLS
|
||||
from app.main_graph.utils.rag_initializer import init_rag_tool
|
||||
from backend.app.main_graph.state import MainGraphState, CurrentAction
|
||||
from backend.app.main_graph.utils.main_graph_builder import build_react_main_graph
|
||||
from backend.app.model_services.chat_services import get_all_chat_services
|
||||
from backend.app.main_graph.tools.graph_tools import AVAILABLE_TOOLS
|
||||
from backend.app.main_graph.utils.rag_initializer import init_rag_tool
|
||||
|
||||
|
||||
# ========== 测试用例配置 ==========
|
||||
|
||||
Reference in New Issue
Block a user