Small fixes.

This commit is contained in:
Fjerkroa Auto 2023-03-24 18:01:57 +01:00
parent b3edc621f6
commit 8aab8e2ec8

View File

@ -128,7 +128,7 @@ class AIResponder(object):
result = await openai.ChatCompletion.acreate(model=self.config["fix-model"],
messages=messages,
temperature=0.2)
return result['chaices'][0]['message']['content']
return result['choices'][0]['message']['content']
except Exception as err:
logging.warning(f"failed to execute a fix for the answer: {repr(err)}")
return answer
@ -143,6 +143,10 @@ class AIResponder(object):
answer, limit = await self._acreate(messages, limit)
if answer is None:
continue
try:
response = json.loads(answer['content'])
except Exception as err:
logging.warning(f"failed to parse the answer: {pformat(err)}\n{repr(answer['content'])}")
answer['content'] = await self.fix(answer['content'])
try:
response = json.loads(answer['content'])