feat: add OptionMatcherEngine plugin type #379
Conversation
…lution Introduces a dedicated engine class for matching free-form user utterances to predefined option slots — semantically distinct from ReRankerEngine (which ranks answers against a semantic query) and modelled after the existing YesNoEngine pattern. Changes: - templates/agents.py: add OptionMatcherEngine with abstract match_option() - utils/__init__.py: add AGENT_OPTION_MATCHER = "opm.agents.option_matcher" to both PluginTypes and PluginConfigTypes - agents.py: add find_option_matcher_plugins() and load_option_matcher_plugin() - test_agents.py: 4 new tests covering find, load, abstract enforcement, and concrete subclass instantiation Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds a new OptionMatcherEngine abstract template, plugin discovery/loading helpers for option matcher plugins, corresponding plugin type enum entries, and unit tests validating discovery, loading, and the abstract contract. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Note Docstrings generation - SUCCESS |
Hello there! I've processed your latest changes. 🌊I've aggregated the results of the automated checks for this PR below. 📋 Repo HealthI've checked the repo's balance (aka feature parity). ⚖️ ✅ All required files present. Latest Version: ✅ 🔒 Security (pip-audit)Ensuring no malicious actors are hitching a ride. 🎭 ✅ No known vulnerabilities found (59 packages scanned). 📊 CoverageEnsuring every logical path is accounted for. 🛣️ ✅ 84.9% total coverage Files below 80% coverage (22 files)
Full report: download the 🏷️ Release PreviewThe release notes are being translated as we speak. 🌍 Current:
✅ PR title follows conventional commit format. 🚀 Release Channel Compatibility Predicted next version:
🔍 LintEvaluating the overall progress of your contribution. 📉 ❌ ruff: issues found — see job log ⚖️ License CheckEnsuring our CLA requirements are met. 🖋️ ✅ No license violations found (40 packages). License distribution: 10× MIT License, 6× Apache Software License, 6× MIT, 4× Apache-2.0, 2× BSD-3-Clause, 2× ISC License (ISCL), 2× PSF-2.0, 2× Python Software Foundation License, +6 more Full breakdown — 40 packages
Copyright (c) 2022 Phil Ewels Permission is hereby granted, free of charge, to any person obtaining a copy The above copyright notice and this permission notice shall be included in all THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR Policy: Apache 2.0 (universal donor). StrongCopyleft / NetworkCopyleft / WeakCopyleft / Other / Error categories fail. MPL allowed. 🔨 Build TestsChecking if the code is ready for prime time. 📺 ✅ All versions pass
Processing completed in 0.0001 bot-seconds ⚡ |
Docstrings generation was requested by @JarbasAl. The following files were modified: * `ovos_plugin_manager/agents.py` * `ovos_plugin_manager/templates/agents.py` * `test/unittests/test_agents.py`
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
ovos_plugin_manager/templates/agents.py (1)
469-485:⚠️ Potential issue | 🟡 MinorHandle empty ranking results before indexing top-1.
At Line 485,
self.rerank(...)[0][1]will raise on emptyoptions(or any empty rerank result). Add an explicit guard and raise a clearer error.💡 Suggested fix
def select_answer(self, query: str, options: List[str], lang: Optional[str] = None, return_index: bool = False) -> Union[str, int]: @@ - return self.rerank(query, options, lang=lang, return_index=return_index)[0][1] + ranked = self.rerank(query, options, lang=lang, return_index=return_index) + if not ranked: + raise ValueError("No ranked options available; ensure `options` is non-empty.") + return ranked[0][1]🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ovos_plugin_manager/templates/agents.py` around lines 469 - 485, The select_answer method currently indexes into the first element of self.rerank(...) without checking for an empty result which will raise IndexError when options is empty; change select_answer to call rerank_result = self.rerank(query, options, lang=lang, return_index=return_index), check if not rerank_result and raise a clear ValueError (e.g. "No candidate options provided or rerank returned empty result in select_answer"), then return the top item from rerank_result[0][1] as before (preserving the return_index behavior).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@ovos_plugin_manager/templates/agents.py`:
- Around line 469-485: The select_answer method currently indexes into the first
element of self.rerank(...) without checking for an empty result which will
raise IndexError when options is empty; change select_answer to call
rerank_result = self.rerank(query, options, lang=lang,
return_index=return_index), check if not rerank_result and raise a clear
ValueError (e.g. "No candidate options provided or rerank returned empty result
in select_answer"), then return the top item from rerank_result[0][1] as before
(preserving the return_index behavior).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 0cad4302-b478-40f6-b4e1-63fce6c5c26a
📒 Files selected for processing (4)
ovos_plugin_manager/agents.pyovos_plugin_manager/templates/agents.pyovos_plugin_manager/utils/__init__.pytest/unittests/test_agents.py
for ask_selection slot resolution
Introduces a dedicated engine class for matching free-form user utterances to predefined option slots — semantically distinct from ReRankerEngine (which ranks answers against a semantic query) and modelled after the existing YesNoEngine pattern.
Changes:
Summary by CodeRabbit
New Features
Tests