Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/poly/resources/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def to_yaml_dict(self) -> dict:

if self.step_type == StepType.DEFAULT_STEP:
output["conditions"] = [condition.to_yaml_dict() for condition in self.conditions]
output["extracted_entities"] = self.extracted_entities
output["extracted_entities"] = sorted(self.extracted_entities)

output["prompt"] = self.prompt
return output
Expand Down
16 changes: 16 additions & 0 deletions src/poly/tests/project_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,22 @@ def test_get_diffs_specific_files(self):
func_path = os.path.join(TEST_DIR, "functions", "extra_function.py")
self.assertNotIn(func_path, diffs)

def test_get_diffs_no_diff_for_reordered_extracted_entities(self):
"""Reordering extracted_entities should not produce a diff."""
project_data = deepcopy(PROJECT_DATA)
# Reverse the extracted_entities order so it differs from local YAML
step = project_data["resources"]["flow_steps"][
"test_flow_with_punctuation!_welcome_step"
]
step["extracted_entities"] = list(reversed(step["extracted_entities"]))
project = AgentStudioProject.from_dict(project_data, TEST_DIR)
diffs = project.get_diffs(all_files=True)

step_path = os.path.join(
"flows", "test_flow_with_punctuation!", "steps", "welcome_step.yaml"
)
self.assertNotIn(step_path, diffs)


class CleanResourcesBeforePushTest(unittest.TestCase):
"""Tests for the _clean_resources_before_push method"""
Expand Down
21 changes: 21 additions & 0 deletions src/poly/tests/resources_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3479,6 +3479,27 @@ def test_read_local_resource_conditions(self):
self.assertEqual(exit_cond.exit_flow_position, {"x": 10.0, "y": 10.0})
self.assertEqual(exit_cond.description, "Exit the flow")

def test_to_yaml_dict_sorts_extracted_entities(self):
"""Extracted entities should be sorted alphabetically in YAML output."""
step = FlowStep(
resource_id="flow-123_step-1",
step_id="step-1",
name="Test Step",
flow_id="flow-123",
flow_name="Test Flow",
step_type=StepType.DEFAULT_STEP,
asr_biasing=None,
dtmf_config=None,
conditions=[],
extracted_entities=["zebra", "apple", "mango"],
prompt="Extract some entities.",
position={"x": 0.0, "y": 0.0},
)

result = step.to_yaml_dict()

self.assertEqual(result["extracted_entities"], ["apple", "mango", "zebra"])


class EntityTests(unittest.TestCase):
def test_validate_entity(self):
Expand Down
Loading