Skip to content

Commit

Permalink
fix: the gpt model has no context (#27)
Browse files Browse the repository at this point in the history
* fix: the gpt model has no context

* chore: remove debug log message to prevent log spam
  • Loading branch information
PocketMiner82 authored Oct 28, 2024
1 parent dba2ada commit cff8b35
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ def build_msg_history(self, message):
ans = None
for m in self.sessions[sess.session_id]:
if m[0] == "user":
q = m[1] # track question
if ans is not None:
if ans is not None and q is not None:
# save previous q/a pair
messages.append((q, ans))
q = None
ans = None
q = m[1] # track question
elif m[0] == "ai":
if ans is None:
ans = m[1] # track answer
Expand All @@ -88,10 +88,11 @@ def build_msg_history(self, message):

def _async_ask(self, message):
utterance = message.data["utterance"]
self.chat.qa_pairs = self.build_msg_history(message)
chat = self.chat
chat.qa_pairs = self.build_msg_history(message)
answered = False
try:
for utt in self.chat.stream_utterances(utterance):
for utt in chat.stream_utterances(utterance):
answered = True
self.speak(utt)
except Exception as err: # speak error on any network issue / no credits etc
Expand Down

0 comments on commit cff8b35

Please sign in to comment.