chore(graph): Relocate QueryAnalysis schema and update existing tests for Orchestrator architecture

This commit is contained in:
Yunxiao Xu
2026-02-23 05:58:58 -08:00
parent ad7845cc6a
commit f4d09c07c4
7 changed files with 199 additions and 227 deletions

View File

@@ -2,7 +2,7 @@ import json
import pytest
import logging
from unittest.mock import patch
from ea_chatbot.graph.workflow import app
from ea_chatbot.graph.workflow import create_workflow
from ea_chatbot.graph.state import AgentState
from ea_chatbot.utils.logging import get_logger
from langchain_community.chat_models import FakeListChatModel
@@ -43,10 +43,10 @@ def test_logging_e2e_json_output(tmp_path):
"question": "Who won in 2024?",
"analysis": None,
"next_action": "",
"plan": None,
"code": None,
"code_output": None,
"error": None,
"iterations": 0,
"checklist": [],
"current_step": 0,
"vfs": {},
"plots": [],
"dfs": {}
}
@@ -57,6 +57,20 @@ def test_logging_e2e_json_output(tmp_path):
fake_clarify = FakeListChatModel(responses=["Please specify."])
# Create a test app without interrupts
# We need to manually compile it here to avoid the global 'app' which has interrupts
from langgraph.graph import StateGraph, END
from ea_chatbot.graph.nodes.query_analyzer import query_analyzer_node
from ea_chatbot.graph.nodes.clarification import clarification_node
workflow = StateGraph(AgentState)
workflow.add_node("query_analyzer", query_analyzer_node)
workflow.add_node("clarification", clarification_node)
workflow.set_entry_point("query_analyzer")
workflow.add_edge("query_analyzer", "clarification")
workflow.add_edge("clarification", END)
test_app = workflow.compile()
with patch("ea_chatbot.graph.nodes.query_analyzer.get_llm_model") as mock_llm_factory:
mock_llm_factory.return_value = fake_analyzer
@@ -64,7 +78,7 @@ def test_logging_e2e_json_output(tmp_path):
mock_clarify_llm_factory.return_value = fake_clarify
# Run the graph
list(app.stream(initial_state))
test_app.invoke(initial_state)
# Verify file content
assert log_file.exists()