Skip to content
This repository has been archived by the owner on Jan 31, 2025. It is now read-only.

fix: the gpt model has no context #27

Merged
merged 3 commits into from
Oct 28, 2024
Merged
Changes from all commits
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
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
Loading