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

Upload/download fix live agent #1514

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hasinaxp
Copy link
Contributor

@hasinaxp hasinaxp commented Sep 17, 2024

optional bot_response in callback action (log failure for no bot_response fix)
added live agent in upload/download

Summary by CodeRabbit

  • New Features

    • Introduced functionality to handle live agent actions, allowing for better management and retrieval.
    • Added a method to list live agent actions associated with a specified bot.
  • Bug Fixes

    • Improved efficiency by ensuring messages are dispatched only when valid responses are available.
  • Tests

    • Added new tests to verify the functionality of live agent actions and updated existing tests to include these actions.

spandan.mondal added 2 commits September 17, 2024 14:44
optional bot_response in callback action (log failure for no bot_response fix)
Copy link

coderabbitai bot commented Sep 17, 2024

Walkthrough

The changes introduced in this pull request enhance the message dispatching logic in the async_callback methods and integrate new functionality for handling live agent actions in the processor.py file. Specifically, the modifications ensure that messages are dispatched only when valid data is available, and a new method for listing live agent actions has been added. Tests have also been updated to validate these new functionalities and ensure proper integration within the existing framework.

Changes

Files Change Summary
kairon/async_callback/processor.py Enhanced conditional logic for dispatching messages to ensure bot_response or data is not empty or None before calling dispatch_message.
kairon/shared/data/processor.py Added list_live_agent_actions method to fetch live agent actions and updated save_integrated_actions and load_action_configurations methods to include live agent actions.
tests/unit_test/data_processor/data_processor_test.py Introduced test_list_live_agent_actions to validate live agent actions retrieval, updated expected outputs for test_download_data_files_with_actions and test_load_action_configurations to include live_agent_action.

Possibly related PRs

Poem

In the meadow where rabbits play,
New features hop in, brightening the day.
With messages sent, not a moment to waste,
Live agents now dance, no time to haste.
Let's celebrate changes, both big and small,
For in this code, we find joy for all! 🐇✨


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 generate interesting stats about this repository and render them as a table.
    -- @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 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

Outside diff range and nitpick comments (2)
kairon/shared/data/processor.py (2)

Line range hint 59-80: The apply_template method looks good overall with one small suggestion.

It handles applying a use-case template correctly, checking if the template directory exists before proceeding.

Using a default sysadmin user for templates seems reasonable.

[suggestion] Consider providing a more specific error message than "Invalid template!" when the template directory does not exist, to help users diagnose the issue.


Line range hint 165-180: The apply_config method looks good overall with one small suggestion.

It handles applying a config template correctly, checking if the config file exists before proceeding.

[suggestion] Consider providing a more specific error message than "Invalid config!" when the config file does not exist, to help users diagnose the issue.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1b7abb2 and 5f616cc.

Files selected for processing (3)
  • kairon/async_callback/processor.py (2 hunks)
  • kairon/shared/data/processor.py (4 hunks)
  • tests/unit_test/data_processor/data_processor_test.py (3 hunks)
Additional comments not posted (16)
kairon/async_callback/processor.py (2)

85-86: LGTM!

The added conditional check is a good improvement. It prevents dispatching empty or None responses, thereby avoiding unnecessary calls to dispatch_message. This enhances the efficiency and robustness of the code.


155-156: LGTM!

The added conditional check is a good improvement. It prevents dispatching empty or None responses, thereby avoiding unnecessary calls to dispatch_message. This enhances the efficiency and robustness of the code, similar to the changes made in the async_callback function.

kairon/shared/data/processor.py (11)

Line range hint 1-27: The upload_and_save method looks good overall.

It handles uploading and saving the training data files correctly, and cleans up the temporary directory after processing. No major issues observed.


Line range hint 29-57: The download_files method looks good overall.

It correctly fetches the various training data objects and packages them into a zip file for download. Using a zip file is an appropriate way to deliver multiple files. No major issues observed.


Line range hint 82-128: The save_from_path method looks good overall.

It handles loading and saving Rasa training data from a directory correctly. Using the RasaFileImporter is the right way to load the various Rasa file formats.

Validating the custom actions using TrainingDataValidator is a good practice.

The loaded data is saved appropriately using self.save_training_data().

No major issues observed.


Line range hint 130-163: The save_training_data method looks good overall.

It provides a flexible way to save different parts of the training data based on the what argument. The overwrite argument is useful to control whether existing data should be replaced.

Delegating the actual saving of individual pieces of data to separate methods is good for modularity and keeping this method concise.

No major issues observed.


Line range hint 182-191: The load_multiflow_stories_yaml method looks good.

It queries the MultiflowStories collection to fetch multiflow stories for a bot and returns the result as a YAML string.

Excluding metadata fields like id, bot, user, timestamp, status from the YAML output is reasonable.

No issues observed.


Line range hint 193-203: The load_bot_content method looks good.

It handles loading bot content correctly, checking the enable_faq flag in bot settings to determine if content should be loaded.

Delegating to self.__prepare_cognition_data_for_bot() to actually fetch the content is good for modularity and keeping this method concise.

No issues observed.


Line range hint 205-255: The __prepare_cognition_data_for_bot method looks good.

It handles fetching cognition data for a bot correctly. Querying the CognitionSchema collection first to get the schema for each collection, and then fetching the corresponding data from CognitionData is a reasonable approach.

The aggregated result format as a list of dictionaries seems appropriate and easy to work with.

No issues observed.


Line range hint 257-268: The get_config_templates method looks good.

It handles fetching the list of available config templates correctly. Using Utility.list_files() is a reasonable way to get the list of config files.

Reading each config file using read_config_file() and returning the config data along with the template name is appropriate.

No issues observed.


Line range hint 270-289: The delete_bot_data method looks good.

It provides a way to delete different parts of bot data based on the what argument, which is useful.

Delegating the actual deletion to separate methods for each type of data (domain, stories, NLU, config, rules, actions, multiflow stories, bot content) is good for modularity and keeping this method concise.

No issues observed.


Line range hint 291-300: The save_nlu method looks good.

It handles saving NLU training data correctly by calling separate methods to save training examples, entity synonyms, lookup tables and regex features.

Delegating the saving of each type of NLU data to separate methods is good for modularity and keeping this method concise.

No issues observed.


Line range hint 302-311: The delete_nlu method looks good.

It handles deleting NLU training data correctly by calling Utility.hard_delete_document() to delete the relevant collections (TrainingExamples, EntitySynonyms, LookupTables, RegexFeatures).

No issues observed.

tests/unit_test/data_processor/data_processor_test.py (3)

1139-1158: LGTM!

The new test method test_list_live_agent_actions is well-structured and thoroughly tests the functionality of loading and listing live agent actions using the MongoProcessor. The assertions cover the expected structure and content of the loaded and listed data.

This addition aligns with the PR objective of enhancing the live agent feature and improves the test coverage.


3588-3588: LGTM!

The modification to the expected output in the test_download_data_files_with_actions method correctly includes live_agent_action in the set of actions being tested. This change ensures that the test method verifies the inclusion of live_agent_action in the downloaded data files.

This update aligns with the PR objective of enhancing the live agent feature and maintains the accuracy of the test.


3625-3625: LGTM!

The modification to the expected output in the test_load_action_configurations method correctly includes live_agent_action in the action configurations being tested. This change ensures that the test method verifies the inclusion of live_agent_action in the loaded action configurations.

This update aligns with the PR objective of enhancing the live agent feature and maintains the accuracy of the test.

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

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