refactor(workflow): simplify edge configuration
This commit is contained in:
@@ -2393,7 +2393,6 @@ class WorkflowBrainTests(unittest.IsolatedAsyncioTestCase):
|
||||
"mode": "llm",
|
||||
"priority": 10,
|
||||
"condition": "需求已收集",
|
||||
"transitionSpeech": "正在为你结束流程",
|
||||
},
|
||||
}
|
||||
],
|
||||
@@ -2569,29 +2568,6 @@ class WorkflowBrainTests(unittest.IsolatedAsyncioTestCase):
|
||||
self.assertTrue(call_end.ending)
|
||||
self.assertTrue(call_end.armed)
|
||||
self.assertTrue(any(getattr(frame, "text", "") == "感谢来电" for frame in queued))
|
||||
transition_context_frames = [
|
||||
frame
|
||||
for frame in worker.frames
|
||||
if isinstance(frame, LLMMessagesAppendFrame)
|
||||
and frame.messages
|
||||
== [
|
||||
{
|
||||
"role": "system",
|
||||
"content": (
|
||||
f"{FIXED_SPEECH_CONTEXT_MARKER}\n正在为你结束流程"
|
||||
),
|
||||
}
|
||||
]
|
||||
]
|
||||
self.assertTrue(transition_context_frames)
|
||||
transition_events = [
|
||||
frame.message
|
||||
for frame in queued
|
||||
if isinstance(frame, OutputTransportMessageUrgentFrame)
|
||||
and frame.message.get("source") == "workflow-edge-transition"
|
||||
]
|
||||
self.assertEqual(transition_events[0]["content"], "正在为你结束流程")
|
||||
self.assertEqual(transition_events[0]["nodeId"], "end")
|
||||
assistant_transcripts = [
|
||||
frame.message.get("content")
|
||||
for frame in queued
|
||||
@@ -2601,11 +2577,7 @@ class WorkflowBrainTests(unittest.IsolatedAsyncioTestCase):
|
||||
]
|
||||
self.assertEqual(
|
||||
assistant_transcripts,
|
||||
["正在为你结束流程", "感谢来电"],
|
||||
)
|
||||
self.assertIn(
|
||||
"正在为你结束流程",
|
||||
brain._store.values["system__conversation_history"],
|
||||
["感谢来电"],
|
||||
)
|
||||
self.assertIn(
|
||||
"感谢来电",
|
||||
|
||||
@@ -64,7 +64,7 @@ class _Brain:
|
||||
|
||||
async def on_client_ready(self):
|
||||
for content, timestamp in (
|
||||
("Start Edge 过渡语", "2026-07-14T10:00:00.200+00:00"),
|
||||
("Message 节点播报", "2026-07-14T10:00:00.200+00:00"),
|
||||
("Agent 固定进入语", "2026-07-14T10:00:00.300+00:00"),
|
||||
):
|
||||
await self.worker.queue_frame(
|
||||
@@ -118,7 +118,7 @@ class PipelineEventTest(unittest.IsolatedAsyncioTestCase):
|
||||
ordered = sorted(transcripts, key=lambda message: message["timestamp"])
|
||||
self.assertEqual(
|
||||
[message["content"] for message in ordered],
|
||||
["助手开场白", "Start Edge 过渡语", "Agent 固定进入语"],
|
||||
["助手开场白", "Message 节点播报", "Agent 固定进入语"],
|
||||
)
|
||||
self.assertEqual(transcripts[0]["timestamp"], greeting_time)
|
||||
self.assertEqual(brain.prepared_greeting, "助手开场白")
|
||||
|
||||
@@ -132,6 +132,17 @@ class WorkflowGraphTests(unittest.TestCase):
|
||||
self.assertEqual(cleaned_agent["data"]["entryMode"], "wait_user")
|
||||
self.assertNotIn("entrySpeech", cleaned_agent["data"])
|
||||
|
||||
def test_edge_speech_fields_are_removed(self):
|
||||
graph = valid_graph()
|
||||
graph["edges"][0]["data"]["transitionSpeech"] = "不再播放"
|
||||
graph["edges"][1]["data"]["transition_speech"] = "旧字段也不再播放"
|
||||
|
||||
normalized = normalize_graph(graph)
|
||||
|
||||
for edge in normalized["edges"]:
|
||||
self.assertNotIn("transitionSpeech", edge["data"])
|
||||
self.assertNotIn("transition_speech", edge["data"])
|
||||
|
||||
def test_action_defaults_preserve_legacy_result_assignment_behavior(self):
|
||||
graph = valid_graph()
|
||||
graph["nodes"].extend(
|
||||
|
||||
Reference in New Issue
Block a user