Skip to content

Commit

Permalink
feat: chat history
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Nov 13, 2024
1 parent 4ba49c8 commit f137184
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ovos_persona/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
from padacioso import IntentContainer

from ovos_persona.solvers import QuestionSolversService
try:
from ovos_plugin_manager.solvers import find_chat_solver_plugins
except ImportError:
def find_chat_solver_plugins():
return {}


class Persona:
Expand All @@ -32,6 +37,11 @@ def __init__(self, name, config, blacklist=None):
plugs[plug_name] = {"enabled": False}
else:
plugs[plug_name] = config.get(plug_name) or {"enabled": True}
for plug_name, plug in find_chat_solver_plugins().items():
if plug_name not in persona or plug_name in blacklist:
plugs[plug_name] = {"enabled": False}
else:
plugs[plug_name] = config.get(plug_name) or {"enabled": True}
self.solvers = QuestionSolversService(config=plugs)

def __repr__(self):
Expand Down
15 changes: 15 additions & 0 deletions ovos_persona/solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
from ovos_utils.log import LOG
from ovos_utils.messagebus import FakeBus
try:
from ovos_plugin_manager.solvers import find_chat_solver_plugins
from ovos_plugin_manager.templates.solvers import ChatMessageSolver
except ImportError:
# using outdated ovos-plugin-manager
class ChatMessageSolver:
pass

def find_chat_solver_plugins():
return {}


class QuestionSolversService:
def __init__(self, bus=None, config=None):
Expand All @@ -32,6 +36,17 @@ def load_plugins(self):
except Exception as e:
LOG.exception(f"Failed to load question solver plugin: {plug_name}")

for plug_name, plug in find_chat_solver_plugins().items():
config = self.config.get(plug_name) or {}
if not config.get("enabled", True):
continue
try:
LOG.debug(f"loading chat plugin with cfg: {config}")
self.loaded_modules[plug_name] = plug(config=config)
LOG.info(f"loaded chat solver plugin: {plug_name}")
except Exception as e:
LOG.exception(f"Failed to load chat solver plugin: {plug_name}")

@property
def modules(self):
return sorted(self.loaded_modules.values(),
Expand Down

0 comments on commit f137184

Please sign in to comment.