From aaba2d61811351c06af4dc75cb9ede5e2ab7aabc Mon Sep 17 00:00:00 2001 From: YueGuobin Date: Thu, 5 Mar 2026 23:19:20 +0800 Subject: [PATCH] docs: update node name from generate_title to title_generator_node Updated references to the title generation node in both documentation and code: - Changed node name from `generate_title` to `title_generator_node` in API design documentation - Updated filtering logic in agent service to exclude `title_generator_node` from LLM call statistics, token counting, and frontend streaming events - Maintains same functionality while using more descriptive node name for clarity --- docs/gns3-copilot/ai-chat-api-design.md | 2 +- .../agent/gns3_copilot/agent_service.py | 20 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/gns3-copilot/ai-chat-api-design.md b/docs/gns3-copilot/ai-chat-api-design.md index 951e96e71..a3e64d987 100644 --- a/docs/gns3-copilot/ai-chat-api-design.md +++ b/docs/gns3-copilot/ai-chat-api-design.md @@ -221,7 +221,7 @@ await conn.execute("CREATE INDEX IF NOT EXISTS idx_pinned_updated ON chat_sessio ### Title 自动同步 -会话标题由 `generate_title` 节点自动生成,保存在 LangGraph checkpoint 的 `conversation_title` 字段中。 +会话标题由 `title_generator_node` 节点自动生成,保存在 LangGraph checkpoint 的 `conversation_title` 字段中。 **同步机制**: 1. 流式 Chat 完成后,从 checkpoint 读取最终 state diff --git a/gns3server/agent/gns3_copilot/agent_service.py b/gns3server/agent/gns3_copilot/agent_service.py index e1a1b54db..034259250 100644 --- a/gns3server/agent/gns3_copilot/agent_service.py +++ b/gns3server/agent/gns3_copilot/agent_service.py @@ -308,19 +308,19 @@ class AgentService: # Track LLM calls and tokens if event_type == "on_chat_model_start": - # Filter out generate_title node from statistics + # Filter out title_generator_node from statistics langgraph_node = event.get("metadata", {}).get("langgraph_node", "") - if langgraph_node != "generate_title": + if langgraph_node != "title_generator_node": llm_calls_count += 1 log.debug("LLM call started, count=%d", llm_calls_count) else: - log.debug("Skipping LLM call count for internal node: generate_title") + log.debug("Skipping LLM call count for internal node: title_generator_node") elif event_type == "on_chat_model_end": - # Filter out generate_title node from token counting + # Filter out title_generator_node from token counting langgraph_node = event.get("metadata", {}).get("langgraph_node", "") - if langgraph_node == "generate_title": - log.debug("Skipping token counting for internal node: generate_title") + if langgraph_node == "title_generator_node": + log.debug("Skipping token counting for internal node: title_generator_node") else: # Extract token usage from response metadata # Try multiple possible locations where token usage might be stored @@ -368,11 +368,11 @@ class AgentService: # Convert event to chunk for SSE streaming # Use accumulator for on_chat_model_stream events to handle progressive tool calls - # Filter out internal nodes (generate_title) from streaming to frontend + # Filter out internal nodes (title_generator_node) from streaming to frontend langgraph_node = event.get("metadata", {}).get("langgraph_node", "") - if langgraph_node == "generate_title": - # Skip all events from the generate_title node (internal use only) - log.debug("Skipping event from internal node: generate_title") + if langgraph_node == "title_generator_node": + # Skip all events from the title_generator_node (internal use only) + log.debug("Skipping event from internal node: title_generator_node") continue if event_type == "on_chat_model_stream":