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

feat/opm_pipeline_plugin #22

Merged
merged 2 commits into from
Jul 20, 2024
Merged

feat/opm_pipeline_plugin #22

merged 2 commits into from
Jul 20, 2024

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented Jul 20, 2024

move pipeline from core into plugin

Summary by CodeRabbit

  • New Features

    • Introduced a new intent recognition service with multi-language support.
    • Added public methods for intent matching at varying confidence levels (high, medium, low).
    • Enhanced integration capabilities with a new plugin entry point for the Padacioso pipeline within the Open Voice OS framework.
  • Bug Fixes

    • Improved handling of dynamic intent and entity registration.
  • Documentation

    • Updated setup configuration to include new plugin entry point details.

move pipeline from core into plugin
@JarbasAl JarbasAl added enhancement New feature or request packaging labels Jul 20, 2024
Copy link
Contributor

coderabbitai bot commented Jul 20, 2024

Warning

Rate limit exceeded

@JarbasAl has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 39 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 92b82ad and b5f3225.

Walkthrough

The recent update introduces the PadaciosoPipeline, a robust intent recognition service that enhances the Padacioso framework. This service supports multi-language intent matching with configurable confidence thresholds and dynamic registration of intents and entities. Furthermore, it integrates with the OVOS plugin system, allowing seamless interaction within the ecosystem. Overall, these changes improve intent recognition capabilities while ensuring performance and flexibility.

Changes

Files Change Summary
padacioso/opm.py Introduced PadaciosoPipeline for intent recognition, PadaciosoIntent for intent details, and several public methods for matching intents at different confidence levels. Enhanced registration of intents and entities.
setup.py Added a new entry point for the ovos-padacioso-pipeline-plugin, enabling integration with the OVOS framework. Updated setup() to include this entry point.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PadaciosoPipeline
    participant MessageBus
    participant IntentMatcher
    
    User->>PadaciosoPipeline: Send utterance
    PadaciosoPipeline->>MessageBus: Broadcast intent matching request
    MessageBus->>IntentMatcher: Evaluate utterances
    IntentMatcher-->>MessageBus: Return matched intent
    MessageBus-->>PadaciosoPipeline: Provide matched intent
    PadaciosoPipeline-->>User: Respond with intent details
Loading

🐇 "In the world of intent, we hop and play,
With Padacioso guiding our way.
Matching words with confidence bright,
Flexibility is our delight!
As plugins unite, we celebrate,
A future of chats that feels just great!" 🐰


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>.
    • 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 show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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
Contributor

@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: 2

Outside diff range, codebase verification and nitpick comments (3)
setup.py (1)

50-50: Define PLUGIN_ENTRY_POINT at the top of the file.

For better readability and maintainability, consider defining PLUGIN_ENTRY_POINT at the top of the file with other constants.

+ PLUGIN_ENTRY_POINT = 'ovos-padacioso-pipeline-plugin=ovos_padacioso.opm:PadaciosoPipeline'
padacioso/opm.py (2)

1-1: Add module-level docstring.

Consider adding a module-level docstring to provide an overview of the module's purpose and functionality.

+ """
+ This module provides the PadaciosoPipeline class and related functionality for intent matching.
+ """

227-232: Clarify docstring.

The docstring mentions compatibility with Padacioso twice, which seems redundant. Consider rephrasing it for clarity.

- Note that this method is NOT compatible with Padacioso, but is compatible with Padacioso.
+ Note that this method is NOT compatible with Padatious, but is compatible with Padacioso.
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 84b7de1 and 92b82ad.

Files selected for processing (2)
  • padacioso/opm.py (1 hunks)
  • setup.py (2 hunks)
Additional context used
Ruff
padacioso/opm.py

191-191: Ambiguous variable name: l

(E741)

Additional comments not posted (1)
setup.py (1)

63-63: LGTM!

The entry point is correctly added to the setup() function.

Comment on lines +284 to +285
# TODO - how to disambiguate ?
intent = ties[0]
Copy link
Contributor

@coderabbitai coderabbitai bot Jul 20, 2024

Choose a reason for hiding this comment

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

TODO: Add disambiguation logic.

The TODO comment suggests adding logic for disambiguation. Consider implementing this or creating an issue to track this task.

Do you want me to generate the disambiguation logic or open a GitHub issue to track this task?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes

Copy link
Contributor

Choose a reason for hiding this comment

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

@JarbasAl, I'll add the disambiguation logic to the _calc_padacioso_intent function. Here's the updated implementation:

@lru_cache(maxsize=3)  # repeat calls under different conf levels wont re-run code
def _calc_padacioso_intent(utt: str,
                           intent_container: FallbackIntentContainer,
                           sess: Session) -> \
        Optional[PadaciosoIntent]:
    """
    Try to match an utterance to an intent in an intent_container
    @param args: tuple of (utterance, IntentContainer)
    @return: matched PadaciosoIntent
    """
    try:
        intents = [i for i in intent_container.calc_intents(utt)
                   if i is not None
                   and i["name"] not in sess.blacklisted_intents
                   and i["name"].split(":")[0] not in sess.blacklisted_skills]
        if len(intents) == 0:
            return None
        best_conf = max(x.get("conf", 0) for x in intents if x.get("name"))
        ties = [i for i in intents if i.get("conf", 0) == best_conf]
        if not ties:
            return None
        # Disambiguation logic: select the intent with the shortest matched phrase
        intent = min(ties, key=lambda i: len(i.get("matches", {}).get("utterance", "")))
        return PadaciosoIntent(intent["name"], utt, intent["matches"], intent["conf"])
    except Exception as e:
        LOG.error(f"Error calculating Padacioso intent: {e}")
        return None

This logic resolves ties by selecting the intent with the shortest matched phrase. If you have any other criteria in mind for disambiguation, please let me know!


Learnings added
Learnt from: JarbasAl
PR: OpenVoiceOS/padacioso#22
File: padacioso/opm.py:284-285
Timestamp: 2024-07-20T17:59:52.692Z
Learning: When multiple intents have the same confidence score, disambiguation logic should be implemented to select the best intent. One approach is to select the intent with the shortest matched phrase.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Copy link
Member Author

Choose a reason for hiding this comment

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

it should prefer the longest matched phrase, not the shortest

Copy link
Contributor

Choose a reason for hiding this comment

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

@JarbasAl, I'll update the disambiguation logic to prefer the longest matched phrase. Here's the revised implementation:

@lru_cache(maxsize=3)  # repeat calls under different conf levels wont re-run code
def _calc_padacioso_intent(utt: str,
                           intent_container: FallbackIntentContainer,
                           sess: Session) -> \
        Optional[PadaciosoIntent]:
    """
    Try to match an utterance to an intent in an intent_container
    @param args: tuple of (utterance, IntentContainer)
    @return: matched PadaciosoIntent
    """
    try:
        intents = [i for i in intent_container.calc_intents(utt)
                   if i is not None
                   and i["name"] not in sess.blacklisted_intents
                   and i["name"].split(":")[0] not in sess.blacklisted_skills]
        if len(intents) == 0:
            return None
        best_conf = max(x.get("conf", 0) for x in intents if x.get("name"))
        ties = [i for i in intents if i.get("conf", 0) == best_conf]
        if not ties:
            return None
        # Disambiguation logic: select the intent with the longest matched phrase
        intent = max(ties, key=lambda i: len(i.get("matches", {}).get("utterance", "")))
        return PadaciosoIntent(intent["name"], utt, intent["matches"], intent["conf"])
    except Exception as e:
        LOG.error(f"Error calculating Padacioso intent: {e}")
        return None

This logic now resolves ties by selecting the intent with the longest matched phrase. Let me know if further adjustments are needed!


Learnings added
Learnt from: JarbasAl
PR: OpenVoiceOS/padacioso#22
File: padacioso/opm.py:284-285
Timestamp: 2024-07-20T18:03:35.671Z
Learning: When multiple intents have the same confidence score, disambiguation logic should be implemented to select the best intent. One approach is to select the intent with the longest matched phrase.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


Learnings used
Learnt from: JarbasAl
PR: OpenVoiceOS/padacioso#22
File: padacioso/opm.py:284-285
Timestamp: 2024-07-20T17:59:52.848Z
Learning: When multiple intents have the same confidence score, disambiguation logic should be implemented to select the best intent. One approach is to select the intent with the shortest matched phrase.

padacioso/opm.py Outdated Show resolved Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@JarbasAl JarbasAl merged commit 4aeb1c6 into dev Jul 20, 2024
13 checks passed
@JarbasAl JarbasAl deleted the feat/opm_pipeline_plugin branch July 20, 2024 18:03
@JarbasAl JarbasAl mentioned this pull request Jul 20, 2024
@coderabbitai coderabbitai bot mentioned this pull request Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request packaging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant