From cff8b3567ffc834e42215f919c6e6d4953a5287b Mon Sep 17 00:00:00 2001 From: PocketMiner82 <73847326+PocketMiner82@users.noreply.github.com> Date: Mon, 28 Oct 2024 22:56:42 +0100 Subject: [PATCH] fix: the gpt model has no context (#27) * fix: the gpt model has no context * chore: remove debug log message to prevent log spam --- __init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/__init__.py b/__init__.py index 0e3c742..021b24c 100644 --- a/__init__.py +++ b/__init__.py @@ -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 @@ -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