Small fixes.
This commit is contained in:
parent
b3edc621f6
commit
8aab8e2ec8
@ -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,12 +143,16 @@ class AIResponder(object):
|
||||
answer, limit = await self._acreate(messages, limit)
|
||||
if answer is None:
|
||||
continue
|
||||
answer['content'] = await self.fix(answer['content'])
|
||||
try:
|
||||
response = json.loads(answer['content'])
|
||||
except Exception as err:
|
||||
logging.error(f"failed to parse the answer: {pformat(err)}\n{repr(answer['content'])}")
|
||||
return AIResponse(None, False, f"ERROR: I could not parse this answer: {repr(answer['content'])}", None, False)
|
||||
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'])
|
||||
except Exception as err:
|
||||
logging.error(f"failed to parse the answer: {pformat(err)}\n{repr(answer['content'])}")
|
||||
return AIResponse(None, False, f"ERROR: I could not parse this answer: {repr(answer['content'])}", None, False)
|
||||
if 'hack' not in response or type(response.get('picture', None)) not in (type(None), str):
|
||||
continue
|
||||
logging.info(f"got this answer:\n{pformat(response)}")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user