From 73a3aaebb3968a7908a3a9e736315a5cce8b2d76 Mon Sep 17 00:00:00 2001 From: JarbasAI <33701864+JarbasAl@users.noreply.github.com> Date: Wed, 16 Oct 2024 10:17:05 +0100 Subject: [PATCH 1/3] feat:pipeline plugin factory (#11) * feat:pipeline plugin factory * feat:pipeline plugin factory * feat:pipeline plugin factory --- ovos_commonqa/opm.py | 28 +++++++++++++++------------- requirements.txt | 2 +- tests/test_common_query.py | 4 ++-- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/ovos_commonqa/opm.py b/ovos_commonqa/opm.py index e06aadb..1bcde86 100644 --- a/ovos_commonqa/opm.py +++ b/ovos_commonqa/opm.py @@ -2,16 +2,18 @@ from dataclasses import dataclass from os.path import dirname from threading import Event -from typing import Dict, Optional +from typing import Dict, Optional, List, Union +from ovos_bus_client.client import MessageBusClient from ovos_bus_client.message import Message from ovos_bus_client.session import SessionManager from ovos_config.config import Configuration from ovos_plugin_manager.solvers import find_multiple_choice_solver_plugins -from ovos_plugin_manager.templates.pipeline import IntentMatch, PipelinePlugin +from ovos_plugin_manager.templates.pipeline import PipelineMatch, PipelineStageMatcher from ovos_utils import flatten_list -from ovos_utils.log import LOG +from ovos_utils.fakebus import FakeBus from ovos_utils.lang import standardize_lang_tag +from ovos_utils.log import LOG from ovos_workshop.app import OVOSAbstractApplication @@ -31,12 +33,13 @@ class Query: selected_skill: str = "" -class CommonQAService(PipelinePlugin, OVOSAbstractApplication): - def __init__(self, bus, config=None): +class CommonQAService(PipelineStageMatcher, OVOSAbstractApplication): + def __init__(self, bus: Optional[Union[MessageBusClient, FakeBus]] = None, + config: Optional[Dict] = None): OVOSAbstractApplication.__init__( self, bus=bus, skill_id="common_query.openvoiceos", resources_dir=f"{dirname(__file__)}") - PipelinePlugin.__init__(self, config) + PipelineStageMatcher.__init__(self, bus, config) self.active_queries: Dict[str, Query] = dict() self.common_query_skills = [] @@ -88,7 +91,7 @@ def is_question_like(self, utterance: str, lang: str): # require a "question word" return self.voc_match(utterance, "QuestionWord", lang) - def match(self, utterances: str, lang: str, message: Message) -> Optional[IntentMatch]: + def match(self, utterances: List[str], lang: str, message: Message) -> Optional[PipelineMatch]: """ Send common query request and select best response @@ -98,7 +101,7 @@ def match(self, utterances: str, lang: str, message: Message) -> Optional[Intent lang (str): Language code message: Message for session context Returns: - IntentMatch or None + PipelineMatch or None """ lang = standardize_lang_tag(lang) # we call flatten in case someone is sending the old style list of tuples @@ -118,11 +121,10 @@ def match(self, utterances: str, lang: str, message: Message) -> Optional[Intent message.data["utterance"] = utterance answered, skill_id = self.handle_question(message) if answered: - match = IntentMatch(intent_service='CommonQuery', - intent_type=True, - intent_data={}, - skill_id=skill_id, - utterance=utterance) + match = PipelineMatch(handled=True, + match_data={}, + skill_id=skill_id, + utterance=utterance) break return match diff --git a/requirements.txt b/requirements.txt index 13956fa..34626f8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ ovos-workshop>=0.1.7,<2.0.0 -ovos-plugin-manager +ovos-plugin-manager>=0.5.0,<1.0.0 ovos-bus-client ovos-config ovos-utils>=0.3.4,<1.0.0 \ No newline at end of file diff --git a/tests/test_common_query.py b/tests/test_common_query.py index c639bc7..0961b75 100644 --- a/tests/test_common_query.py +++ b/tests/test_common_query.py @@ -32,7 +32,7 @@ def test_init(self): self.assertEqual(len(self.bus.ee.listeners("common_query.question")), 1) def test_is_question_like(self): - lang = "en-us" + lang = "en-US" self.assertTrue(self.cc.is_question_like("what is a computer", lang)) self.assertTrue(self.cc.is_question_like("tell me about computers", lang)) @@ -142,7 +142,7 @@ def test_common_query_events(self): 'data': {'utterance': 'answer 1', 'expect_response': False, 'meta': {'skill': 'wiki.test'}, - 'lang': 'en-us'}, + 'lang': 'en-US'}, 'context': skill_ans_ctxt}, # handler complete event {'type': 'mycroft.skill.handler.complete', From 51b396f47f584f30f99ec57362dd1d96e6b404d6 Mon Sep 17 00:00:00 2001 From: JarbasAl Date: Wed, 16 Oct 2024 09:17:18 +0000 Subject: [PATCH 2/3] Increment Version to 1.0.0a1 --- ovos_commonqa/version.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ovos_commonqa/version.py b/ovos_commonqa/version.py index 7b0dd49..cd3bcb6 100644 --- a/ovos_commonqa/version.py +++ b/ovos_commonqa/version.py @@ -1,6 +1,6 @@ # START_VERSION_BLOCK -VERSION_MAJOR = 0 -VERSION_MINOR = 1 -VERSION_BUILD = 4 -VERSION_ALPHA = 0 +VERSION_MAJOR = 1 +VERSION_MINOR = 0 +VERSION_BUILD = 0 +VERSION_ALPHA = 1 # END_VERSION_BLOCK From 6f4ebe4e7821eefe370b6b80c48241395351740e Mon Sep 17 00:00:00 2001 From: JarbasAl Date: Wed, 16 Oct 2024 09:17:40 +0000 Subject: [PATCH 3/3] Update Changelog --- CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94f2e99..3b8d3e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,12 @@ # Changelog -## [0.1.4a1](https://github.com/OpenVoiceOS/ovos-common-query-pipeline-plugin/tree/0.1.4a1) (2024-10-16) +## [1.0.0a1](https://github.com/OpenVoiceOS/ovos-common-query-pipeline-plugin/tree/1.0.0a1) (2024-10-16) -[Full Changelog](https://github.com/OpenVoiceOS/ovos-common-query-pipeline-plugin/compare/0.1.3...0.1.4a1) +[Full Changelog](https://github.com/OpenVoiceOS/ovos-common-query-pipeline-plugin/compare/0.1.4...1.0.0a1) -**Merged pull requests:** +**Breaking changes:** -- fix:standardize\_lang [\#9](https://github.com/OpenVoiceOS/ovos-common-query-pipeline-plugin/pull/9) ([JarbasAl](https://github.com/JarbasAl)) +- feat:pipeline plugin factory [\#11](https://github.com/OpenVoiceOS/ovos-common-query-pipeline-plugin/pull/11) ([JarbasAl](https://github.com/JarbasAl))