Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:persona name #38

Merged
merged 2 commits into from
Jan 31, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions ovos_persona/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def load_personas(self, personas_path: Optional[str] = None):
continue
with open(f"{personas_path}/{p}") as f:
persona = json.load(f)
name = persona.get("name", name)
LOG.info(f"Found persona (user defined): {name}")
try:
self.personas[name] = Persona(name, persona)
Expand Down Expand Up @@ -301,13 +302,15 @@ def match_high(self, utterances: List[str], lang: Optional[str] = None,
skill_id="persona.openvoiceos",
utterance=utterances[0])
elif name == "ask.intent":
utterance = match["entities"].pop("query")
return IntentHandlerMatch(match_type='persona:query',
match_data={"utterance": utterance,
"lang": lang,
"persona": persona},
skill_id="persona.openvoiceos",
utterance=utterances[0])
persona = self.get_persona(persona)
if persona: # else the name isnt a persona, so dont match
utterance = match["entities"].pop("query")
return IntentHandlerMatch(match_type='persona:query',
match_data={"utterance": utterance,
"lang": lang,
"persona": persona},
skill_id="persona.openvoiceos",
utterance=utterances[0])
JarbasAl marked this conversation as resolved.
Show resolved Hide resolved

# override regular intent parsing, handle utterance until persona is released
if self.active_persona:
Expand Down Expand Up @@ -434,13 +437,16 @@ def stop_session(self, session: Session):

if __name__ == "__main__":
LOG.set_level("DEBUG")
b = PersonaService(FakeBus(), config={"personas_path": "/home/miro/PycharmProjects/HiveMind-rpi-hub/overlays/home/ovos/.config/ovos_persona"})
b = PersonaService(FakeBus(),
config={
"default_persona": "ChatBot",
"personas_path": "/home/miro/PycharmProjects/HiveMind-rpi-hub/overlays/home/ovos/.config/ovos_persona"})
JarbasAl marked this conversation as resolved.
Show resolved Hide resolved
print("Personas:", b.personas)

print(b.match_high(["enable remote llama"]))

# b.handle_persona_query(Message("", {"utterance": "tell me about yourself"}))
for ans in b.chatbox_ask("what are you"):
for ans in b.chatbox_ask("what is the speed of light"):
print(ans)
# The speed of light has a value of about 300 million meters per second
# The telephone was invented by Alexander Graham Bell
Expand Down
Loading