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

Fallback Data while file upload #1596

Conversation

maheshsattala
Copy link
Contributor

@maheshsattala maheshsattala commented Nov 13, 2024

added code related to handling the extra creation of nlu fallback data while uploading the files.

Summary by CodeRabbit

  • New Features

    • Enhanced data import functionality with support for file uploads.
    • Improved configuration management to handle different scenarios for file uploads.
    • New conversational agent actions and configurations for greeting and saying goodbye.
    • Introduction of a structured approach for managing intents, responses, and actions in the conversational framework.
  • Bug Fixes

    • Enhanced validation for HTTP actions and configuration files to ensure required parameters are present.

Copy link

coderabbitai bot commented Nov 13, 2024

Walkthrough

The changes involve modifications to the DataImporter and MongoProcessor classes to enhance their functionality related to file uploads. The import_data method in DataImporter now includes a file_upload parameter, which is passed to the save_training_data method. In MongoProcessor, similar updates were made to the add_or_overwrite_config and add_default_fallback_config methods, incorporating the file_upload parameter to manage configurations based on file uploads. Additional logic for validating and saving configurations has also been introduced.

Changes

File Path Change Summary
kairon/importer/data_importer.py Updated import_data method to include file_upload=True.
kairon/shared/data/processor.py Modified MongoProcessor methods:
- add_or_overwrite_config now accepts file_upload.
- add_default_fallback_config now accepts file_upload and conditionally calls add_default_fallback_data.
- Enhanced save_training_data to include file_upload.
- Updated save_data_without_event to validate and save HTTP actions and configuration files.
tests/testing_data/validator/valid_data/actions.yml Added two new HTTP actions: action_say_hello and action_say_goodbye.
tests/testing_data/validator/valid_data/chat_client_config.yml Introduced new configuration file for chat client settings.
tests/testing_data/validator/valid_data/config.yml Added new configuration for ML pipeline including various components and policies.
tests/testing_data/validator/valid_data/data/nlu.yml Created new NLU intents: greet and deny.
tests/testing_data/validator/valid_data/data/rules.yml Added new rules for conversational agent behavior.
tests/testing_data/validator/valid_data/data/stories.yml Introduced new stories for conversational agent interactions.
tests/testing_data/validator/valid_data/domain.yml Created new domain configuration with intents, responses, and actions.
tests/unit_test/events/events_test.py Enhanced tests for MessageBroadcastEvent class with new scenarios and validations.
tests/unit_test/validator/data_importer_test.py Added new tests for DataImporter class, enhancing validation coverage.

Poem

In the meadow where data flows,
A rabbit hops where the processor glows.
With uploads now, our tasks align,
Configs and training, all intertwine.
Hooray for changes, let’s celebrate,
With file uploads, we elevate! 🐇✨


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

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

572-572: Add docstring to save_training_data method including file_upload parameter

Consider adding a docstring to save_training_data method to explain its functionality and describe the parameters, including the new file_upload parameter.


Line range hint 2135-2139: Update docstring to include file_upload parameter

The add_or_overwrite_config method's docstring should be updated to include the new file_upload parameter, explaining its purpose and usage.

🧰 Tools
🪛 Ruff

2133-2133: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


5406-5406: Add docstring to add_default_fallback_config method including file_upload parameter

Consider adding a docstring to add_default_fallback_config method to explain its functionality and to describe the parameters, including the new file_upload parameter.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d271fed and 33959e2.

📒 Files selected for processing (2)
  • kairon/importer/data_importer.py (1 hunks)
  • kairon/shared/data/processor.py (6 hunks)
🔇 Additional comments (4)
kairon/importer/data_importer.py (1)

59-60: Verify handling of non-file-upload scenarios

The hardcoded file_upload=True parameter might affect existing non-file-upload scenarios. Let's verify how this parameter is used in the MongoProcessor.

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

589-589: LGTM

The addition of the file_upload parameter in the call to add_or_overwrite_config ensures consistent propagation of the parameter.


2146-2146: LGTM

The inclusion of the file_upload parameter in the call to add_default_fallback_config correctly passes the parameter for further processing.


5453-5454: LGTM

The conditional check on file_upload appropriately determines whether to add default fallback data when not uploading from a file.

Comment on lines +59 to +60
self.overwrite, self.files_to_save,
file_upload=True)
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider making file_upload parameter configurable

The file_upload parameter is hardcoded to True, which means all imports will be treated as file uploads. Consider making this configurable through the constructor or method parameter to support different import scenarios.

- file_upload=True)
+ file_upload: bool = True)

And update the constructor:

 def __init__(self, path: Text, bot: Text, user: Text, files_to_save: set, save_data: bool = True,
-             overwrite: bool = True):
+             overwrite: bool = True, file_upload: bool = True):
     """Initialize data importer"""
     self.path = path
     self.bot = bot
     self.user = user
     self.save_data = save_data
     self.overwrite = overwrite
     self.files_to_save = files_to_save
+    self.file_upload = file_upload

Committable suggestion skipped: line range outside the PR's diff.

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

🧹 Outside diff range and nitpick comments (14)
tests/testing_data/validator/valid_data/data/nlu.yml (2)

3-7: Consider expanding greet examples for better intent recognition.

While the basic greetings are covered, consider adding more variations to improve the model's robustness:

  • Common variations like "hey there", "hi there", "howdy"
  • Formal greetings like "good morning", "good afternoon"
  • Casual variations like "yo", "hiya"
 - intent: greet
   examples: |
     - hey
     - hello
     - hi
+    - hey there
+    - hi there
+    - good morning
+    - good afternoon
+    - howdy

8-13: Consider adding contextual deny examples.

The current deny examples are good but could benefit from more context-specific variations that might occur in real conversations:

  • Polite refusals
  • Context-specific denials
 - intent: deny
   examples: |
     - no
     - never
     - I don't think so
     - don't like that
+    - no thanks
+    - not really
+    - I'll pass
+    - not interested
tests/testing_data/validator/valid_data/domain.yml (3)

1-3: Consider selective entity storage configuration

While store_entities_as_slots: true provides automatic slot creation, it might create unnecessary slots for all entities. Consider configuring this at the intent level for more precise control.

 config:
-  store_entities_as_slots: true
+  store_entities_as_slots: false

Then specify it for specific intents where needed:

intents:
- intent_name:
    use_entities: true
    store_entities_as_slots: true

7-11: Simplify intent configuration

The use_entities: true configuration is redundant as it's the default behavior. You can simplify the intent declarations unless you need to explicitly document this behavior.

 intents:
-  - greet:
-      use_entities: true
-  - deny:
-      use_entities: true
+  - greet
+  - deny

12-20: Consider consolidating similar responses and adding variations

  1. utter_default and utter_please_rephrase serve similar purposes. Consider consolidating them.
  2. Single-response templates might lead to repetitive bot behavior. Consider adding variations.
 responses:
   utter_goodbye:
   - text: Bye
+  - text: Goodbye! Have a great day!
+  - text: See you later!
   utter_greet:
   - text: Hey! How are you?
+  - text: Hello! Nice to meet you!
+  - text: Hi there! How can I help you today?
-  utter_default:
-    - text: Can you rephrase!
   utter_please_rephrase:
     - text: I'm sorry, I didn't quite understand that. Could you rephrase?
+    - text: I didn't catch that. Could you say it differently?
+    - text: I'm not sure what you mean. Can you rephrase that?
tests/testing_data/validator/valid_data/config.yml (3)

12-13: Consider lowering the FallbackClassifier threshold

The current threshold of 0.75 is quite high and might result in too many fallbacks to the default response. A threshold between 0.3 and 0.6 is typically more balanced.

- threshold: 0.75
+ threshold: 0.5

14-15: Consider increasing DIETClassifier epochs

5 epochs might be insufficient for the DIETClassifier to learn effectively, especially with complex intents. Consider increasing to 100-150 epochs for better model performance.

- epochs: 5
+ epochs: 100

21-23: Increase TEDPolicy epochs for better learning

Similar to the DIETClassifier, 5 epochs for TEDPolicy is likely insufficient. Consider increasing to improve dialogue management.

- epochs: 5
+ epochs: 100
tests/testing_data/validator/valid_data/actions.yml (1)

25-25: Add newline at end of file

Add a newline character at the end of the file to comply with YAML formatting standards.

🧰 Tools
🪛 yamllint

[error] 25-25: no new line character at the end of file

(new-line-at-end-of-file)

tests/testing_data/validator/valid_data/data/rules.yml (1)

7-13: Consider additional slot validation

While the rule correctly checks for the location slot, consider adding validation for the slot value itself.

 - rule: Only say `hello` if the user provided a location
   condition:
   - slot_was_set:
-    - location: true
+    - location: {"type": "text", "value": !null}
   steps:
   - intent: greet
   - action: utter_greet
tests/unit_test/validator/data_importer_test.py (3)

124-134: Clarify the purpose of this additional test

This test appears to be very similar to test_import_data but uses a different test data path. Consider:

  1. Adding comments to explain how this test case differs from test_import_data
  2. Renaming the test to better reflect its specific purpose
  3. Documenting the key differences in the test data between 'valid' and 'valid_data' directories

212-212: Consider adding fallback data test cases

Given that this PR focuses on "Fallback Data while file upload", consider adding specific test cases to verify:

  1. Fallback data creation during file upload
  2. Validation of fallback configurations
  3. Edge cases in fallback data handling

Line range hint 1-250: Enhance test coverage for fallback data functionality

While the test file has good coverage for basic import scenarios, it lacks specific tests for the fallback data functionality mentioned in the PR objectives. Consider adding:

  1. Test cases for fallback data creation during file upload
  2. Validation of fallback configurations
  3. Error cases for invalid fallback data
  4. Integration tests with MongoProcessor's fallback-related methods

This will ensure the new functionality is properly tested and maintained.

tests/unit_test/events/events_test.py (1)

840-840: Remove unnecessary print statements in unit tests

The print statements on lines 840 and 843 are unnecessary and can clutter the test output. Consider removing them.

Apply this diff to remove the print statements:

-     print(list(mongo_processor.fetch_responses(bot)))
-     print(mongo_processor.fetch_rule_block_names(bot))

Also applies to: 843-843

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 33959e2 and f2b215f.

📒 Files selected for processing (9)
  • tests/testing_data/validator/valid_data/actions.yml (1 hunks)
  • tests/testing_data/validator/valid_data/chat_client_config.yml (1 hunks)
  • tests/testing_data/validator/valid_data/config.yml (1 hunks)
  • tests/testing_data/validator/valid_data/data/nlu.yml (1 hunks)
  • tests/testing_data/validator/valid_data/data/rules.yml (1 hunks)
  • tests/testing_data/validator/valid_data/data/stories.yml (1 hunks)
  • tests/testing_data/validator/valid_data/domain.yml (1 hunks)
  • tests/unit_test/events/events_test.py (4 hunks)
  • tests/unit_test/validator/data_importer_test.py (4 hunks)
✅ Files skipped from review due to trivial changes (2)
  • tests/testing_data/validator/valid_data/chat_client_config.yml
  • tests/testing_data/validator/valid_data/data/stories.yml
🧰 Additional context used
🪛 yamllint
tests/testing_data/validator/valid_data/actions.yml

[error] 25-25: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (16)
tests/testing_data/validator/valid_data/data/nlu.yml (2)

1-2: LGTM! Valid YAML structure and version.

The version "3.1" is correctly specified and the NLU section is properly declared.


1-13: Verify test coverage for fallback scenarios.

Since this file is in the testing data directory and the PR focuses on fallback data during file upload, we should verify that:

  1. The test data adequately covers fallback scenarios
  2. There are sufficient edge cases for testing the fallback behavior
✅ Verification successful

Let me check the content of the rules.yml and config.yml files to verify the fallback configurations.


Fallback scenarios are adequately covered in test data

The test data includes comprehensive fallback configurations and test scenarios:

  • NLU fallback is handled via FallbackClassifier with a confidence threshold of 0.75
  • Core fallback is configured with RulePolicy (threshold: 0.3, action: action_small_talk)
  • A dedicated rule exists for handling low confidence NLU scenarios with utter_please_rephrase
  • Multiple test files contain fallback-related test cases across integration and unit tests
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for related test files and fallback configurations

# Look for related test files
echo "Searching for related test files..."
fd -e yml -e yaml . tests/testing_data/validator/valid_data/data/ -x echo "Found test file: {}"

# Check for fallback configurations
echo "Checking for fallback configurations..."
rg -l "fallback" tests/testing_data/validator/valid_data/

# Look for test cases related to fallback
echo "Searching for fallback-related test cases..."
rg -l "test.*fallback" tests/

Length of output: 1252


Script:

#!/bin/bash
# Check content of fallback-related configuration files
echo "Content of rules.yml:"
cat tests/testing_data/validator/valid_data/data/rules.yml

echo -e "\nContent of config.yml:"
cat tests/testing_data/validator/valid_data/config.yml

# Search for fallback-related content in test files
echo -e "\nFallback-related content in test files:"
rg "fallback" -A 3 -B 3 tests/testing_data/validator/valid_data/

Length of output: 2579

tests/testing_data/validator/valid_data/config.yml (2)

1-2: LGTM: Basic configuration is properly set

The recipe version and language settings are correctly configured.


24-26: Verify core_fallback_threshold effectiveness

The core_fallback_threshold of 0.3 is quite low and might trigger the fallback action too frequently. Consider testing with different thresholds to find the optimal balance.

✅ Verification successful

The core_fallback_threshold of 0.3 is consistent with standard configurations

Based on the analysis of the codebase:

  • The threshold value of 0.3 is commonly used across multiple configuration files, including templates and use-cases
  • Production-ready configurations like template/config/rasa-default.yml and various use-case templates also use 0.3
  • Some configurations use 0.5 for specific scenarios (like multiflow stories and long-answer cases)
  • Only one test configuration uses a higher threshold of 0.75

The current threshold of 0.3 appears to be a well-established value in the codebase and doesn't require adjustment unless specific use-case metrics indicate otherwise.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any custom implementation of action_small_talk
rg -l "action_small_talk" --type python

# Check if there are any existing fallback configurations in other files
rg -l "core_fallback_threshold" --type yaml

Length of output: 1696


Script:

#!/bin/bash
# Let's check the core_fallback_threshold values in these config files
rg "core_fallback_threshold:" -B2 -A2

# Also check for any custom fallback action implementations
rg "action_small_talk" --type-add 'py:*.py' --type py

Length of output: 17439

tests/testing_data/validator/valid_data/actions.yml (1)

1-13: Add error handling and timeout configuration for HTTP action

The HTTP action configuration could be more robust with the following improvements:

  1. Add request timeout configuration
  2. Include error handling for failed requests
  3. Validate response data before using ${data}

Example configuration structure:

http_action:
- action_name: action_say_hello
  content_type: json
  headers: []
  http_url: https://jsonplaceholder.typicode.com/posts/1
  params_list: []
  request_method: GET
  timeout: 5000  # milliseconds
  response:
    dispatch: true
    dispatch_type: text
    evaluation_type: expression
    value: ${data}
    fallback_value: "Sorry, I couldn't fetch the data"
    validation:
      schema: ${data != null}
  set_slots: []
tests/testing_data/validator/valid_data/data/rules.yml (3)

15-19: Verify rule precedence with location-based greeting

The rule looks good, but ensure it doesn't conflict with the location-based greeting rule. Consider documenting the expected behavior when both rules could apply.

#!/bin/bash
# Check for any other conversation start rules that might conflict
rg "conversation_start:\s*true" --type yaml

1-5: LGTM! Verify fallback response exists

The fallback rule implementation follows best practices for handling low confidence scenarios.


21-25: Consider loop prevention mechanism

The rule correctly uses wait_for_user_input: false, but ensure the utter_greet response doesn't trigger conditions that could lead back to this rule.

✅ Verification successful

No loop risk detected in utter_greet responses

After reviewing the utter_greet responses across the codebase, they only contain simple greeting text responses like "Hey! How are you?" without any elements that could trigger the greeting intent again. The rule's wait_for_user_input: false setting is safe to use in this context.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check the greet response for potential triggers
rg "utter_greet:" -A 5 "domain.yml"

Length of output: 178


Script:

#!/bin/bash
# Search for domain files with different extensions
fd "domain" --type f

# Search for utter_greet in all files
rg "utter_greet:" -A 5

Length of output: 13162

tests/unit_test/validator/data_importer_test.py (2)

162-162: Verify changes in multiflow test data

The test now expects 7 responses and 3 rule blocks. This change should be validated against the test data.

#!/bin/bash
# Description: Verify the number of responses and rule blocks in multiflow test data
# Expected: Should find 7 responses and 3 rule blocks

echo "Checking responses and rules in multiflow test data:"
rg "responses:" tests/testing_data/multiflow_stories/valid_with_multiflow/
rg "rules:" tests/testing_data/multiflow_stories/valid_with_multiflow/

Also applies to: 164-164


115-123: Verify the reduction in rule block count

The test now expects 3 rule blocks instead of the previous 4. This change should be validated against the test data in 'tests/testing_data/validator/valid' to ensure it accurately reflects the intended structure.

✅ Verification successful

Rule block count verification is accurate

The test data in tests/testing_data/validator/valid/data/rules.yml contains exactly 3 rule blocks:

  1. "Only say hello if the user provided a location"
  2. "Say hello when the user starts a conversation with intent greet"
  3. "Rule which will not wait for user message once it was applied"

The assertion assert len(processor.fetch_rule_block_names(bot)) == 3 correctly matches the actual number of rules in the test data.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the number of rule blocks in the test data
# Expected: Should find 3 rule blocks in the test data

echo "Checking rule blocks in test data:"
rg -l "rules:" tests/testing_data/validator/valid/

Length of output: 420


Script:

#!/bin/bash
# Let's check the actual content of rules.yml in the test data directory
echo "Content of rules.yml in valid test data:"
cat tests/testing_data/validator/valid/data/rules.yml

# Also check if there are any other YAML files that might contain rules
echo -e "\nSearching for other YAML files that might contain rules:"
fd -e yml -e yaml . tests/testing_data/validator/valid/ --exec cat {}

Length of output: 4377

tests/unit_test/events/events_test.py (6)

259-261: Assertions added for responses and rule block names

The assertions on lines 259 and 261 correctly verify the expected number of responses and rule block names.


305-305: Added assertion for rule block names

The assertion on line 305 accurately checks the expected number of rule block names.


341-343: Assertions for responses and rule block names are appropriate

The added assertions on lines 341 and 343 ensure the correct number of responses and rule block names are present.


839-839: Assertion for training examples count is correct

The assertion on line 839 correctly verifies the number of training examples fetched.


842-842: Assertion for zero actions is valid

The assertion on line 842 correctly ensures that no actions are fetched, as expected in this context.


845-881: New test test_trigger_data_importer_with_valid_data is well-implemented

The test function added between lines 845 and 881 effectively verifies the data importer with valid data. Good work on improving test coverage.

Comment on lines +4 to +6
session_config:
session_expiration_time: 60
carry_over_slots_to_new_session: true
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Review session expiration time

A 60-second session expiration time is unusually short and might interrupt user conversations. Consider increasing this value to a more reasonable duration (e.g., 30-60 minutes) unless there's a specific requirement for such short sessions.

 session_config:
-  session_expiration_time: 60
+  session_expiration_time: 1800  # 30 minutes in seconds
   carry_over_slots_to_new_session: true
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
session_config:
session_expiration_time: 60
carry_over_slots_to_new_session: true
session_config:
session_expiration_time: 1800 # 30 minutes in seconds
carry_over_slots_to_new_session: true

Comment on lines +22 to +26
actions:
- action_say_hello
- action_say_goodbye
- utter_greet
- utter_goodbye
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

🛠️ Refactor suggestion

Custom actions are missing implementations

The custom actions action_say_hello and action_say_goodbye are defined in the domain file but their implementations (ActionSayHello and ActionSayGoodbye classes) are not found in the codebase. Additionally, the utterance actions are redundant as they are automatically registered from responses.

  • Remove utter_greet and utter_goodbye from the actions section
  • Implement the missing custom actions ActionSayHello and ActionSayGoodbye in your actions file
  • Configure the action server endpoint in endpoints.yml by uncommenting the action_endpoint section
🔗 Analysis chain

Verify custom action implementations and remove redundant utterance actions

  1. Utterance actions (utter_*) don't need to be listed in the actions section as they're automatically registered from responses.
  2. Custom actions need corresponding implementations.
 actions:
 - action_say_hello
 - action_say_goodbye
-  - utter_greet
-  - utter_goodbye

Let me try another search strategy to find the action implementations.


Let me check the content of the actions files to specifically look for ActionSayHello and ActionSayGoodbye implementations.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for custom action implementations
echo "Searching for action implementations..."
rg -l "class (ActionSayHello|ActionSayGoodbye)" -t python

# Verify action server configuration
echo "Checking action server configuration..."
fd "endpoints.yml" | xargs cat

Length of output: 3211


Script:

#!/bin/bash
# Search for action implementations using fd and grep
echo "Searching for action implementations..."
fd -e py | xargs grep -l "class Action"

# Also check for any actions.py file
echo -e "\nChecking for actions.py files..."
fd "actions.py"

Length of output: 1361


Script:

#!/bin/bash
# Search for specific action implementations
echo "Searching for ActionSayHello and ActionSayGoodbye..."
rg "class ActionSayHello|class ActionSayGoodbye" -A 5 kairon/chat/actions.py kairon/actions/definitions/*

Length of output: 1062

Comment on lines +7 to +12
- name: CountVectorsFeaturizer
- analyzer: char_wb
max_ngram: 4
min_ngram: 1
name: CountVectorsFeaturizer
- name: FallbackClassifier
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove duplicate CountVectorsFeaturizer

There appear to be two instances of CountVectorsFeaturizer in the pipeline. This might be unintentional and could impact performance.

Suggested fix:

- name: CountVectorsFeaturizer
- analyzer: char_wb
  max_ngram: 4
  min_ngram: 1
  name: CountVectorsFeaturizer
+ name: CountVectorsFeaturizer
+ analyzer: char_wb
+ max_ngram: 4
+ min_ngram: 1

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +14 to +25
- action_name: action_say_goodbye
content_type: json
headers: []
http_url: https://jsonplaceholder.typicode.com/posts/1
params_list: []
request_method: GET
response:
dispatch: true
dispatch_type: text
evaluation_type: expression
value: ${data}
set_slots: []
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Reduce configuration duplication using YAML anchors

Both actions have identical configurations except for their names. Consider using YAML anchors and aliases to maintain DRY principles.

http_action:
- action_name: action_say_hello
+ &base_action
  content_type: json
  headers: []
  http_url: https://jsonplaceholder.typicode.com/posts/1
  params_list: []
  request_method: GET
  response:
    dispatch: true
    dispatch_type: text
    evaluation_type: expression
    value: ${data}
  set_slots: []
- action_name: action_say_goodbye
-  content_type: json
-  headers: []
-  http_url: https://jsonplaceholder.typicode.com/posts/1
-  params_list: []
-  request_method: GET
-  response:
-    dispatch: true
-    dispatch_type: text
-    evaluation_type: expression
-    value: ${data}
-  set_slots: []
+ action_name: action_say_goodbye
+ <<: *base_action

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 yamllint

[error] 25-25: no new line character at the end of file

(new-line-at-end-of-file)

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.

1 participant