-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixed utterrence for multiflow, slot initialization for numerical,list and boolean slot #1790
Conversation
…st and boolean slot
WalkthroughThe changes update the slot type mappings and event handling in the AgenticFlow class. The "boolean" slot key was renamed to "bool" and a new "mappings" argument was added for bool, float, and list types. Furthermore, the execute_event method now processes BOT events starting with "utter_". In parallel, the multiflow structure in the tests was enhanced by adding a new utter_greet connection and step, updating assertions and the expected event map accordingly. Changes
Sequence Diagram(s)sequenceDiagram
participant E as Event Source
participant A as AgenticFlow
participant R as Responses List
E->>A: execute_event(event)
alt Event type is BOT & starts with "utter_"
A->>R: Append bot utterance to responses
else Other Event
A->>R: Process normally
end
A-->>E: Return responses
sequenceDiagram
participant T as Test Executor
participant M as Multiflow
participant P as py_ans_a Node
participant U as utter_greet Step
T->>M: Initiate multiflow execution
M->>P: Process py_ans_a step
P->>U: Transition to utter_greet action
U-->>M: Register action execution
M-->>T: Return updated flow including utter_greet
Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
kairon/shared/chat/agent/agent_flow.py (1)
226-228
: Consider refactoring duplicate utterance handling logic.The handling of "utter_" events is duplicated between action and BOT event types. Consider extracting this logic into a helper method:
+ def _handle_utterance(self, name: str): + self.responses.append(self.get_utterance_response(name)) + self.executed_actions.append(name) + async def execute_event(self, event: dict): if event['type'] == 'action': if event['name'] == "...": return elif event['name'].startswith("utter_"): - self.responses.append(self.get_utterance_response(event['name'])) - self.executed_actions.append(event['name']) + self._handle_utterance(event['name']) return try: action = KRemoteAction( name=event['name'], action_endpoint=self.action_endpoint ) new_events_for_tracker = await action.run(output_channel=None, nlg=self.nlg, tracker=self.fake_tracker, domain=self.domain) self.process_tracker_events(new_events_for_tracker) self.fake_tracker.events.extend(new_events_for_tracker) self.executed_actions.append(event['name']) except Exception as e: logger.error(f"Error in executing action [{event['name']}]: {e}") raise AppException(f"Error in executing action [{event['name']}]") elif event['type'] == 'BOT' and event['name'].startswith("utter_"): - self.responses.append(self.get_utterance_response(event['name'])) - self.executed_actions.append(event['name']) + self._handle_utterance(event['name'])tests/unit_test/agentic_flow_test.py (1)
389-389
: Remove debug print statement.The print statement appears to be used for debugging and should be removed.
- print(flow.executed_actions)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
kairon/shared/chat/agent/agent_flow.py
(2 hunks)tests/unit_test/agentic_flow_test.py
(4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Python CI
- GitHub Check: Analyze (python)
🔇 Additional comments (3)
kairon/shared/chat/agent/agent_flow.py (2)
29-32
: LGTM! Consistent slot type mapping updates.The changes improve consistency by:
- Renaming "boolean" to "bool" to align with Python's built-in type naming.
- Adding the "mappings" argument to bool, float, and list slot types for uniformity.
Also applies to: 39-40, 43-44
203-229
: LGTM! Good test coverage for the new BOT event type.The test cases in
tests/unit_test/agentic_flow_test.py
thoroughly verify:
- The handling of BOT events starting with "utter_"
- The responses and executed_actions for both action and BOT events
🧰 Tools
🪛 Ruff (0.8.2)
225-225: Within an
except
clause, raise exceptions withraise ... from err
orraise ... from None
to distinguish them from errors in exception handling(B904)
tests/unit_test/agentic_flow_test.py (1)
206-220
: LGTM! Well-structured multiflow test data.The new step and connection for the "utter_greet" BOT event are correctly structured with:
- Proper node and component IDs
- Correct event type (BOT)
- Empty connections array as it's a terminal node
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approved
Summary by CodeRabbit