Skip to content
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

Merged
merged 1 commit into from
Feb 10, 2025

Conversation

hasinaxp
Copy link
Contributor

@hasinaxp hasinaxp commented Feb 7, 2025

Summary by CodeRabbit

  • New Features
    • Bot responses are now consistently captured during conversations, resulting in a more fluid and comprehensive chat experience.
    • An integrated greeting action has been added to conversation flows to promote smoother and more natural interactions.

Copy link

coderabbitai bot commented Feb 7, 2025

Walkthrough

The 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

File Change Summary
kairon/.../agent_flow.py Renamed "boolean" to "bool" in SLOT_TYPE_MAP; added "mappings" argument for bool, float, and list types; inserted a branch in execute_event to handle BOT utterances starting with "utter_".
tests/.../agentic_flow_test.py Updated multiflow structure with a new utter_greet connection and step; modified assertions and expected event map to include the utter_greet action.

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
Loading
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
Loading

Possibly related PRs

  • Agentic flow imp #1780: Related to AgenticFlow modifications in the execute_event method that handle new BOT event flows.

Suggested reviewers

  • sfahad1414

Poem

Hi, I'm a coding rabbit, hopping through the code,
With new mappings and flows on my winding road.
I see "bool" shine where "boolean" once stood,
And bot utterances now are processed as they should.
Hopping with joy, I nibble at the fresh code seed—
Carrots and commits, fulfilling every need!
🥕🐰 Happy coding in our burrow of speed!

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between d71acd1 and 0d864ff.

📒 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:

  1. Renaming "boolean" to "bool" to align with Python's built-in type naming.
  2. 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:

  1. The handling of BOT events starting with "utter_"
  2. The responses and executed_actions for both action and BOT events
🧰 Tools
🪛 Ruff (0.8.2)

225-225: Within an except clause, raise exceptions with raise ... from err or raise ... 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:

  1. Proper node and component IDs
  2. Correct event type (BOT)
  3. Empty connections array as it's a terminal node

Copy link
Collaborator

@hiteshghuge hiteshghuge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved

@hiteshghuge hiteshghuge merged commit 550c090 into digiteinfotech:master Feb 10, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants