Skip to content

Commit ffb2b0c

Browse files
committed
refactor!: opm agents plugins
1 parent 43c4db5 commit ffb2b0c

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
lines changed

ovos_solver_aiml_plugin/__init__.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
from datetime import date
44
from os import listdir, remove as remove_file, makedirs
55
from os.path import dirname, isfile, isdir
6-
from typing import Optional
7-
from ovos_plugin_manager.templates.solvers import QuestionSolver
6+
from typing import Dict, Optional, List, Any, Tuple
7+
8+
from ovos_plugin_manager.templates.agents import RetrievalEngine
89
from ovos_utils.log import LOG
910
from ovos_utils.xdg_utils import xdg_data_home
1011

@@ -94,31 +95,29 @@ def shutdown(self):
9495
self.kernel.resetBrain() # Manual remove
9596

9697

97-
class AIMLSolver(QuestionSolver):
98-
def __init__(self, config=None):
98+
class AIMLSolver(RetrievalEngine):
99+
def __init__(self, config: Optional[Dict[str, Any]] = None):
99100
config = config or {"lang": "en-us"}
100101
lang = config.get("lang") or "en-us"
101102
if lang != "en-us" and lang not in os.listdir(AimlBot.XDG_PATH):
102-
config["lang"] = lang = "en-us"
103-
super().__init__(config, internal_lang=lang, enable_tx=True, priority = 95)
104-
self.brain = AimlBot(lang)
103+
config["lang"] = "en-us"
104+
super().__init__(config)
105+
self.brain = AimlBot(self.config.get("lang"))
105106
self.brain.load_brain()
106107

107-
def get_spoken_answer(self, query: str,
108-
lang: Optional[str] = None,
109-
units: Optional[str] = None) -> Optional[str]:
108+
def query(self, query: str, lang: Optional[str] = None, k: int = 3) -> List[Tuple[str, float]]:
110109
"""
111-
Obtain the spoken answer for a given query.
110+
Searches the knowledge base for relevant documents or data.
112111
113112
Args:
114-
query (str): The query text.
115-
lang (Optional[str]): Optional language code. Defaults to None.
116-
units (Optional[str]): Optional units for the query. Defaults to None.
113+
query: The search string.
114+
lang: BCP-47 language code.
115+
k: The maximum number of results to return.
117116
118117
Returns:
119-
str: The spoken answer as a text response.
118+
List of tuples (content, score) for the top k matches.
120119
"""
121-
return self.brain.ask(query)
120+
return [(self.brain.ask(query), 0.5)]
122121

123122

124123
if __name__ == "__main__":

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
aiml
2-
ovos-plugin-manager>=0.0.26,<3.0.0
2+
ovos-plugin-manager>=2.2.3a1,<3.0.0

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ def get_version():
4747
setup(
4848
name='ovos-solver-aiml-plugin',
4949
version=get_version(),
50-
description='A question solver plugin for ovos/neon/mycroft',
50+
description='A chatbot plugin for OpenVoiceOS',
5151
url='https://github.com/OpenVoiceOS/ovos-solver-aiml-plugin',
5252
author='jarbasai',
5353
author_email='jarbasai@mailfence.com',
5454
license='MIT',
5555
packages=['ovos_solver_aiml_plugin'],
5656
zip_safe=True,
57-
keywords='mycroft plugin utterance fallback query',
58-
entry_points={'neon.plugin.solver': PLUGIN_ENTRY_POINT},
57+
keywords='OpenVoiceOS OVOS plugin utterance fallback query',
58+
entry_points={'opm.agents.retrieval': PLUGIN_ENTRY_POINT},
5959
install_requires=required("requirements.txt"),
6060
long_description=long_description,
6161
long_description_content_type='text/markdown'

0 commit comments

Comments
 (0)