Skip to content

Commit

Permalink
feat/streaming (#18)
Browse files Browse the repository at this point in the history
* feat/streaming

streaming endpoint, faster responses!

* Update requirements.txt

* Update __init__.py
  • Loading branch information
JarbasAl authored Feb 14, 2024
1 parent 8c95bcb commit e4b7104
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
19 changes: 9 additions & 10 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,8 @@ def runtime_requirements(self):
return RuntimeRequirements(
internet_before_load=True,
network_before_load=True,
gui_before_load=False,
requires_internet=True,
requires_network=True,
requires_gui=False,
no_internet_fallback=False,
no_network_fallback=False,
no_gui_fallback=True,
requires_network=True
)

def initialize(self):
Expand Down Expand Up @@ -75,11 +70,15 @@ def build_msg_history(self, message):
def _async_ask(self, message):
utterance = message.data["utterance"]
self.chat.qa_pairs = self.build_msg_history(message)
answer = self.chat.get_spoken_answer(utterance)
if not answer:
answered = False
try:
for utt in self.chat.stream_utterances(utterance):
answered = True
self.speak(utt)
except: # speak error on any network issue / no credits etc
pass
if not answered:
self.speak_dialog("gpt_error")
else:
self.speak(answer)

def ask_chatgpt(self, message):
if "key" not in self.settings:
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ovos-solver-openai-persona-plugin
ovos-solver-openai-persona-plugin>=0.0.0a8
ovos-utils~=0.0, >=0.0.28
ovos_workshop~=0.0, >=0.0.11
ovos-plugin-manager~=0.0, >=0.0.23a13
ovos-translate-server-plugin
ovos-plugin-manager~=0.0, >=0.0.26a9
ovos-translate-server-plugin

0 comments on commit e4b7104

Please sign in to comment.