ovos-solver-hivemind-plugin 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,85 @@
1
+ Metadata-Version: 2.1
2
+ Name: ovos-solver-hivemind-plugin
3
+ Version: 0.0.1
4
+ Summary: A question solver plugin for OVOS
5
+ Home-page: https://github.com/JarbasHiveMind/ovos-solver-hivemind-plugin
6
+ Author: jarbasai
7
+ Author-email: jarbasai@mailfence.com
8
+ License: MIT
9
+ Keywords: OVOS openvoiceos plugin utterance fallback query
10
+ Description-Content-Type: text/markdown
11
+
12
+ # HiveMind solver
13
+
14
+ exposes a hivemind connection as a solver plugin
15
+
16
+ use cases:
17
+ - allow your apps to get responses from a remote HiveMind
18
+ - expose HiveMind to any OpenAI compatible UI, via [ovos-persona-server](https://github.com/OpenVoiceOS/ovos-persona-server)
19
+ - Integrate HiveMind/OVOS into a [MOS (Mixture Of Solvers)](https://github.com/TigreGotico/ovos-MoS)
20
+
21
+ ## Install
22
+
23
+ `pip install ovos-solver-hivemind-plugin`
24
+
25
+ ## Setup
26
+
27
+ You need to register the solver in the HiveMind server
28
+ ```bash
29
+ $ hivemind-core add-client
30
+ Credentials added to database!
31
+
32
+ Node ID: 2
33
+ Friendly Name: HiveMind-Node-2
34
+ Access Key: 5a9e580a2773a262cbb23fe9759881ff
35
+ Password: 9b247ca66c7cd2b6388ad49ca504279d
36
+ Encryption Key: 4185240103de0770
37
+ WARNING: Encryption Key is deprecated, only use if your client does not support password
38
+ ```
39
+
40
+ And then set the identity file in the satellite device (where the solver will run)
41
+ ```bash
42
+ $ hivemind-client set-identity --key 5a9e580a2773a262cbb23fe9759881ff --password 9b247ca66c7cd2b6388ad49ca504279d --host 0.0.0.0 --port 5678 --siteid test
43
+ identity saved: /home/miro/.config/hivemind/_identity.json
44
+ ```
45
+
46
+ check the created identity file if you like
47
+ ```bash
48
+ $ cat ~/.config/hivemind/_identity.json
49
+ {
50
+ "password": "9b247ca66c7cd2b6388ad49ca504279d",
51
+ "access_key": "5a9e580a2773a262cbb23fe9759881ff",
52
+ "site_id": "test",
53
+ "default_port": 5678,
54
+ "default_master": "ws://0.0.0.0"
55
+ }
56
+ ```
57
+
58
+ test that a connection is possible using the identity file
59
+ ```bash
60
+ $ hivemind-client test-identity
61
+ (...)
62
+ 2024-05-20 21:22:28.003 - OVOS - hivemind_bus_client.client:__init__:112 - INFO - Session ID: 34d75c93-4e65-4ea9-b5f4-87169dcfda01
63
+ (...)
64
+ == Identity successfully connected to HiveMind!
65
+ ```
66
+
67
+ ## Usage
68
+
69
+ For usage with any solver framework, such as persona, use `"ovos-solver-hivemind-plugin"` for the solver id
70
+
71
+ Standalone usage
72
+
73
+ ```python
74
+ from ovos_hivemind_solver import HiveMindSolver
75
+
76
+ bot = HiveMindSolver()
77
+ bot.connect() # connection info from identity file
78
+ print(bot.spoken_answer("what is the speed of light?"))
79
+ ```
80
+
81
+ ## Credits
82
+
83
+ ![image](https://github.com/user-attachments/assets/809588a2-32a2-406c-98c0-f88bf7753cb4)
84
+
85
+ > This work was sponsored by VisioLab, part of [Royal Dutch Visio](https://visio.org/), is the test, education, and research center in the field of (innovative) assistive technology for blind and visually impaired people and professionals. We explore (new) technological developments such as Voice, VR and AI and make the knowledge and expertise we gain available to everyone.
@@ -0,0 +1,74 @@
1
+ # HiveMind solver
2
+
3
+ exposes a hivemind connection as a solver plugin
4
+
5
+ use cases:
6
+ - allow your apps to get responses from a remote HiveMind
7
+ - expose HiveMind to any OpenAI compatible UI, via [ovos-persona-server](https://github.com/OpenVoiceOS/ovos-persona-server)
8
+ - Integrate HiveMind/OVOS into a [MOS (Mixture Of Solvers)](https://github.com/TigreGotico/ovos-MoS)
9
+
10
+ ## Install
11
+
12
+ `pip install ovos-solver-hivemind-plugin`
13
+
14
+ ## Setup
15
+
16
+ You need to register the solver in the HiveMind server
17
+ ```bash
18
+ $ hivemind-core add-client
19
+ Credentials added to database!
20
+
21
+ Node ID: 2
22
+ Friendly Name: HiveMind-Node-2
23
+ Access Key: 5a9e580a2773a262cbb23fe9759881ff
24
+ Password: 9b247ca66c7cd2b6388ad49ca504279d
25
+ Encryption Key: 4185240103de0770
26
+ WARNING: Encryption Key is deprecated, only use if your client does not support password
27
+ ```
28
+
29
+ And then set the identity file in the satellite device (where the solver will run)
30
+ ```bash
31
+ $ hivemind-client set-identity --key 5a9e580a2773a262cbb23fe9759881ff --password 9b247ca66c7cd2b6388ad49ca504279d --host 0.0.0.0 --port 5678 --siteid test
32
+ identity saved: /home/miro/.config/hivemind/_identity.json
33
+ ```
34
+
35
+ check the created identity file if you like
36
+ ```bash
37
+ $ cat ~/.config/hivemind/_identity.json
38
+ {
39
+ "password": "9b247ca66c7cd2b6388ad49ca504279d",
40
+ "access_key": "5a9e580a2773a262cbb23fe9759881ff",
41
+ "site_id": "test",
42
+ "default_port": 5678,
43
+ "default_master": "ws://0.0.0.0"
44
+ }
45
+ ```
46
+
47
+ test that a connection is possible using the identity file
48
+ ```bash
49
+ $ hivemind-client test-identity
50
+ (...)
51
+ 2024-05-20 21:22:28.003 - OVOS - hivemind_bus_client.client:__init__:112 - INFO - Session ID: 34d75c93-4e65-4ea9-b5f4-87169dcfda01
52
+ (...)
53
+ == Identity successfully connected to HiveMind!
54
+ ```
55
+
56
+ ## Usage
57
+
58
+ For usage with any solver framework, such as persona, use `"ovos-solver-hivemind-plugin"` for the solver id
59
+
60
+ Standalone usage
61
+
62
+ ```python
63
+ from ovos_hivemind_solver import HiveMindSolver
64
+
65
+ bot = HiveMindSolver()
66
+ bot.connect() # connection info from identity file
67
+ print(bot.spoken_answer("what is the speed of light?"))
68
+ ```
69
+
70
+ ## Credits
71
+
72
+ ![image](https://github.com/user-attachments/assets/809588a2-32a2-406c-98c0-f88bf7753cb4)
73
+
74
+ > This work was sponsored by VisioLab, part of [Royal Dutch Visio](https://visio.org/), is the test, education, and research center in the field of (innovative) assistive technology for blind and visually impaired people and professionals. We explore (new) technological developments such as Voice, VR and AI and make the knowledge and expertise we gain available to everyone.
@@ -0,0 +1,68 @@
1
+ from hivemind_bus_client import HiveMessageBusClient
2
+ from ovos_bus_client.message import Message
3
+ from ovos_plugin_manager.templates.solvers import QuestionSolver
4
+ from ovos_utils.log import LOG
5
+ from threading import Event
6
+
7
+
8
+ class HiveMindSolver(QuestionSolver):
9
+ def __init__(self, config=None):
10
+ config = config or {}
11
+ super().__init__(config, enable_tx=False, priority = 70)
12
+ self.hm = None
13
+ self._response = Event()
14
+ self._responses = []
15
+ if self.config.get("autoconnect"):
16
+ self.connect()
17
+
18
+ def bind(self, hm: HiveMessageBusClient):
19
+ """if you want to re-use a open connection"""
20
+ self.hm = hm
21
+
22
+ def connect(self):
23
+ """assume identity set beforehand, eg via `hivemind-client set-identity`
24
+ """
25
+ self.hm = HiveMessageBusClient(useragent="ovos-hivemind-solver")
26
+ self.hm.connect()
27
+ self.hm.on_mycroft("speak", self._receive_answer)
28
+ self.hm.on_mycroft("ovos.utterance.handled", self._end_of_response)
29
+
30
+ def _end_of_response(self, message):
31
+ self._response.set()
32
+
33
+ def _receive_answer(self, message):
34
+ utt = message.data["utterance"]
35
+ self._responses.append(utt)
36
+
37
+ # abstract Solver methods
38
+ def get_data(self, query, context=None):
39
+ return {"answer": self.get_spoken_answer(query, context)}
40
+
41
+ def get_spoken_answer(self, query, context=None, timeout=10):
42
+ if self.hm is None:
43
+ LOG.error("not connected to HiveMind")
44
+ return
45
+ self._response.clear()
46
+ self._responses = []
47
+
48
+ context = context or {}
49
+ if "session" in context:
50
+ lang = context["session"]["lang"]
51
+ else:
52
+ lang = context.get("lang") or self.config.get("lang", "en-us")
53
+ mycroft_msg = Message("recognizer_loop:utterance",
54
+ {"utterances": [query], "lang": lang})
55
+ self.hm.emit_mycroft(mycroft_msg)
56
+ self._response.wait(timeout=timeout)
57
+ if self._responses:
58
+ # merge multiple speak messages into one
59
+ return "\n".join(self._responses)
60
+ return None # let next solver attempt
61
+
62
+
63
+ if __name__ == "__main__":
64
+ cfg = {
65
+ "autoconnect": True
66
+ }
67
+ bot = HiveMindSolver(config=cfg)
68
+ print(bot.spoken_answer("what is the speed of light?"))
@@ -0,0 +1,7 @@
1
+ # The following lines are replaced during the release process.
2
+ # START_VERSION_BLOCK
3
+ VERSION_MAJOR = 0
4
+ VERSION_MINOR = 0
5
+ VERSION_BUILD = 1
6
+ VERSION_ALPHA = 0
7
+ # END_VERSION_BLOCK
@@ -0,0 +1,85 @@
1
+ Metadata-Version: 2.1
2
+ Name: ovos-solver-hivemind-plugin
3
+ Version: 0.0.1
4
+ Summary: A question solver plugin for OVOS
5
+ Home-page: https://github.com/JarbasHiveMind/ovos-solver-hivemind-plugin
6
+ Author: jarbasai
7
+ Author-email: jarbasai@mailfence.com
8
+ License: MIT
9
+ Keywords: OVOS openvoiceos plugin utterance fallback query
10
+ Description-Content-Type: text/markdown
11
+
12
+ # HiveMind solver
13
+
14
+ exposes a hivemind connection as a solver plugin
15
+
16
+ use cases:
17
+ - allow your apps to get responses from a remote HiveMind
18
+ - expose HiveMind to any OpenAI compatible UI, via [ovos-persona-server](https://github.com/OpenVoiceOS/ovos-persona-server)
19
+ - Integrate HiveMind/OVOS into a [MOS (Mixture Of Solvers)](https://github.com/TigreGotico/ovos-MoS)
20
+
21
+ ## Install
22
+
23
+ `pip install ovos-solver-hivemind-plugin`
24
+
25
+ ## Setup
26
+
27
+ You need to register the solver in the HiveMind server
28
+ ```bash
29
+ $ hivemind-core add-client
30
+ Credentials added to database!
31
+
32
+ Node ID: 2
33
+ Friendly Name: HiveMind-Node-2
34
+ Access Key: 5a9e580a2773a262cbb23fe9759881ff
35
+ Password: 9b247ca66c7cd2b6388ad49ca504279d
36
+ Encryption Key: 4185240103de0770
37
+ WARNING: Encryption Key is deprecated, only use if your client does not support password
38
+ ```
39
+
40
+ And then set the identity file in the satellite device (where the solver will run)
41
+ ```bash
42
+ $ hivemind-client set-identity --key 5a9e580a2773a262cbb23fe9759881ff --password 9b247ca66c7cd2b6388ad49ca504279d --host 0.0.0.0 --port 5678 --siteid test
43
+ identity saved: /home/miro/.config/hivemind/_identity.json
44
+ ```
45
+
46
+ check the created identity file if you like
47
+ ```bash
48
+ $ cat ~/.config/hivemind/_identity.json
49
+ {
50
+ "password": "9b247ca66c7cd2b6388ad49ca504279d",
51
+ "access_key": "5a9e580a2773a262cbb23fe9759881ff",
52
+ "site_id": "test",
53
+ "default_port": 5678,
54
+ "default_master": "ws://0.0.0.0"
55
+ }
56
+ ```
57
+
58
+ test that a connection is possible using the identity file
59
+ ```bash
60
+ $ hivemind-client test-identity
61
+ (...)
62
+ 2024-05-20 21:22:28.003 - OVOS - hivemind_bus_client.client:__init__:112 - INFO - Session ID: 34d75c93-4e65-4ea9-b5f4-87169dcfda01
63
+ (...)
64
+ == Identity successfully connected to HiveMind!
65
+ ```
66
+
67
+ ## Usage
68
+
69
+ For usage with any solver framework, such as persona, use `"ovos-solver-hivemind-plugin"` for the solver id
70
+
71
+ Standalone usage
72
+
73
+ ```python
74
+ from ovos_hivemind_solver import HiveMindSolver
75
+
76
+ bot = HiveMindSolver()
77
+ bot.connect() # connection info from identity file
78
+ print(bot.spoken_answer("what is the speed of light?"))
79
+ ```
80
+
81
+ ## Credits
82
+
83
+ ![image](https://github.com/user-attachments/assets/809588a2-32a2-406c-98c0-f88bf7753cb4)
84
+
85
+ > This work was sponsored by VisioLab, part of [Royal Dutch Visio](https://visio.org/), is the test, education, and research center in the field of (innovative) assistive technology for blind and visually impaired people and professionals. We explore (new) technological developments such as Voice, VR and AI and make the knowledge and expertise we gain available to everyone.
@@ -0,0 +1,11 @@
1
+ README.md
2
+ setup.py
3
+ ovos_hivemind_solver/__init__.py
4
+ ovos_hivemind_solver/version.py
5
+ ovos_solver_hivemind_plugin.egg-info/PKG-INFO
6
+ ovos_solver_hivemind_plugin.egg-info/SOURCES.txt
7
+ ovos_solver_hivemind_plugin.egg-info/dependency_links.txt
8
+ ovos_solver_hivemind_plugin.egg-info/entry_points.txt
9
+ ovos_solver_hivemind_plugin.egg-info/requires.txt
10
+ ovos_solver_hivemind_plugin.egg-info/top_level.txt
11
+ ovos_solver_hivemind_plugin.egg-info/zip-safe
@@ -0,0 +1,2 @@
1
+ [neon.plugin.solver]
2
+ ovos-solver-hivemind-plugin = ovos_hivemind_solver:HiveMindSolver
@@ -0,0 +1,3 @@
1
+ ovos-plugin-manager
2
+ ovos-translate-server-plugin
3
+ hivemind_bus_client>=0.0.4a21
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env python3
2
+ import os
3
+
4
+ from setuptools import setup
5
+
6
+ BASEDIR = os.path.abspath(os.path.dirname(__file__))
7
+
8
+ with open(f"{BASEDIR}/README.md", "r") as fh:
9
+ long_desc = fh.read()
10
+
11
+
12
+ def get_version():
13
+ """ Find the version of the package"""
14
+ version = None
15
+ version_file = os.path.join(BASEDIR, 'ovos_hivemind_solver', 'version.py')
16
+ major, minor, build, alpha = (None, None, None, None)
17
+ with open(version_file) as f:
18
+ for line in f:
19
+ if 'VERSION_MAJOR' in line:
20
+ major = line.split('=')[1].strip()
21
+ elif 'VERSION_MINOR' in line:
22
+ minor = line.split('=')[1].strip()
23
+ elif 'VERSION_BUILD' in line:
24
+ build = line.split('=')[1].strip()
25
+ elif 'VERSION_ALPHA' in line:
26
+ alpha = line.split('=')[1].strip()
27
+
28
+ if ((major and minor and build and alpha) or
29
+ '# END_VERSION_BLOCK' in line):
30
+ break
31
+ version = f"{major}.{minor}.{build}"
32
+ if int(alpha):
33
+ version += f"a{alpha}"
34
+ return version
35
+
36
+
37
+ def required(requirements_file):
38
+ """ Read requirements file and remove comments and empty lines. """
39
+ with open(os.path.join(BASEDIR, requirements_file), 'r') as f:
40
+ requirements = f.read().splitlines()
41
+ if 'MYCROFT_LOOSE_REQUIREMENTS' in os.environ:
42
+ print('USING LOOSE REQUIREMENTS!')
43
+ requirements = [r.replace('==', '>=').replace('~=', '>=') for r in requirements]
44
+ return [pkg for pkg in requirements
45
+ if pkg.strip() and not pkg.startswith("#")]
46
+
47
+
48
+ PLUGIN_ENTRY_POINT = 'ovos-solver-hivemind-plugin=ovos_hivemind_solver:HiveMindSolver'
49
+ setup(
50
+ name='ovos-solver-hivemind-plugin',
51
+ version=get_version(),
52
+ description='A question solver plugin for OVOS',
53
+ url='https://github.com/JarbasHiveMind/ovos-solver-hivemind-plugin',
54
+ author='jarbasai',
55
+ author_email='jarbasai@mailfence.com',
56
+ license='MIT',
57
+ packages=['ovos_hivemind_solver'],
58
+ zip_safe=True,
59
+ keywords='OVOS openvoiceos plugin utterance fallback query',
60
+ entry_points={'neon.plugin.solver': PLUGIN_ENTRY_POINT},
61
+ install_requires=required("requirements.txt"),
62
+ long_description=long_desc,
63
+ long_description_content_type='text/markdown'
64
+ )