Skip to content

Commit

Permalink
Code review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
markbackman committed Dec 18, 2024
1 parent 0feeaf6 commit 00f9be1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/pipecat_flows/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def __init__(
else:
self.nodes = {}
self.initial_node = None
self.initial_system_message = None
self.transition_callback = transition_callback
logger.debug("Initialized in dynamic mode")

Expand Down Expand Up @@ -134,7 +135,7 @@ async def initialize(self, initial_messages: Optional[List[dict]] = None) -> Non
logger.warning("Initial messages ignored for static flow configuration")

# Set initial system message if present
if hasattr(self, "initial_system_message"):
if self.initial_system_message:
await self.task.queue_frame(
LLMMessagesUpdateFrame(messages=self.initial_system_message)
)
Expand Down
14 changes: 10 additions & 4 deletions tests/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,17 +732,23 @@ async def test_static_flow_without_initial_system_message(self):
)

await flow_manager.initialize()

# Verify initialization succeeded
self.assertTrue(flow_manager.initialized)

# Verify initialization succeeded without errors
# No need to check message content since there's no initial system message
# Verify no initial system message was queued
calls = self.mock_task.queue_frame.call_args_list
update_frame_calls = [
call for call in calls if isinstance(call[0][0], LLMMessagesUpdateFrame)
]
self.assertEqual(
len(update_frame_calls),
0,
"No LLMMessagesUpdateFrame should be queued when there's no initial system message",
)

# There should be at least one update frame (from the initial node)
self.assertGreater(len(update_frame_calls), 0)
# Verify node was set
self.assertEqual(flow_manager.current_node, "start")

async def test_static_flow_ignores_initial_messages(self):
"""Test that static flows ignore passed initial messages."""
Expand Down

0 comments on commit 00f9be1

Please sign in to comment.