Skip to content

Commit

Permalink
feat:streaming support
Browse files Browse the repository at this point in the history
stream utterances for speed
  • Loading branch information
JarbasAl committed Nov 13, 2024
1 parent 22b3713 commit 92c29ef
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions ovos_persona/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,10 @@ def chatbox_ask(self, prompt: str,
messages.append({"role": "user", "content": prompt})
if stream:
yield from self.personas[persona].stream(messages, lang)
ans = self.personas[persona].chat(messages, lang)
if ans:
yield ans
else:
ans = self.personas[persona].chat(messages, lang)
if ans:
yield ans

def _build_msg_history(self, message: Message):
sess = SessionManager.get(message)
Expand Down Expand Up @@ -256,7 +257,7 @@ def match_low(self, utterances: List[str], lang: Optional[str] = None,
return IntentHandlerMatch(match_type='persona:query',
match_data={"utterance": utterances[0],
"lang": lang,
"persona": self.active_persona},
"persona": self.active_persona or self.default_persona},
skill_id="persona.openvoiceos",
utterance=utterances[0])

Expand Down Expand Up @@ -310,7 +311,8 @@ def handle_persona_release(self, message):
print(b.personas)

print(b.match_low(["what is the speed of light"]))

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
# Stephen William Hawking (8 January 1942 – 14 March 2018) was an English theoretical physicist, cosmologist, and author who, at the time of his death, was director of research at the Centre for Theoretical Cosmology at the University of Cambridge.
Expand Down

0 comments on commit 92c29ef

Please sign in to comment.