Skip to content

Commit

Permalink
fix:handle "None" answers
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Feb 2, 2025
1 parent 716221e commit ffa5e17
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions ovos_persona/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@

from ovos_config.config import Configuration
from ovos_config.locations import get_xdg_config_save_path
from ovos_config.meta import get_xdg_base
from ovos_persona.solvers import QuestionSolversService

from ovos_bus_client import Session
from ovos_utils.xdg_utils import xdg_data_home
from ovos_config.meta import get_xdg_base
from ovos_bus_client.client import MessageBusClient
from ovos_bus_client.message import Message, dig_for_message
from ovos_bus_client.session import SessionManager
from ovos_plugin_manager.persona import find_persona_plugins
from ovos_plugin_manager.solvers import find_question_solver_plugins
from ovos_plugin_manager.templates.pipeline import PipelineStageConfidenceMatcher, IntentHandlerMatch
from ovos_utils import flatten_list
from ovos_utils.bracket_expansion import expand_template
from ovos_utils.fakebus import FakeBus
from ovos_utils.lang import standardize_lang_tag, get_language_dir
from ovos_utils.log import LOG
from ovos_utils.parse import match_one, MatchStrategy
from ovos_utils.xdg_utils import xdg_data_home
from ovos_workshop.app import OVOSAbstractApplication

try:
Expand All @@ -33,11 +35,8 @@ def find_chat_solver_plugins():
except ImportError:
from padacioso import IntentContainer
IS_PADATIOUS = False

LOG.warning("'padatious' not installed, using 'padacioso' for Persona intents")

from ovos_utils import flatten_list
from ovos_utils.bracket_expansion import expand_template


class Persona:
Expand Down Expand Up @@ -80,9 +79,8 @@ def __init__(self, bus: Optional[Union[MessageBusClient, FakeBus]] = None,
config: Optional[Dict] = None):
bus = bus or FakeBus()
config = config or Configuration().get("intents", {}).get("persona", {})
OVOSAbstractApplication.__init__(
self, bus=bus, skill_id="persona.openvoiceos",
resources_dir=f"{dirname(__file__)}")
OVOSAbstractApplication.__init__(self, bus=bus, skill_id="persona.openvoiceos",
resources_dir=f"{dirname(__file__)}")
PipelineStageConfidenceMatcher.__init__(self, bus=bus, config=config)
self.sessions = {}
self.personas = {}
Expand Down Expand Up @@ -210,6 +208,8 @@ def chatbox_ask(self, prompt: str,
LOG.error(f"unknown persona, choose one of {self.personas.keys()}")
return None
messages = []
# TODO - history per persona , not only per session
# dont let context leak between personas
message = message or dig_for_message()
if message:
for q, a in self._build_msg_history(message):
Expand Down Expand Up @@ -399,8 +399,9 @@ def handle_persona_query(self, message):
if not self._active_sessions[sess.session_id]: # stopped
LOG.debug(f"Persona stopped: {persona}")
return
self.speak(ans)
handled = True
if ans: # might be None
self.speak(ans)
handled = True
if not handled:
self.speak_dialog("persona_error", {"persona": persona})
self._active_sessions[sess.session_id] = False
Expand Down

0 comments on commit ffa5e17

Please sign in to comment.