Try to fix the fix.
This commit is contained in:
parent
b82477fc83
commit
2cd66b55ee
@ -136,7 +136,14 @@ class AIResponder(object):
|
||||
result = await openai.ChatCompletion.acreate(model=self.config["fix-model"],
|
||||
messages=messages,
|
||||
temperature=0.2)
|
||||
return result['choices'][0]['message']['content']
|
||||
logging.info(f"got this message as fix:\n{pformat(result['choices'][0]['message']['content'])}")
|
||||
response = result['choices'][0]['message']['content']
|
||||
start, end = response.find("```"), response.rfind("```")
|
||||
if start == -1 or end == -1 or (start + 3) >= end:
|
||||
return answer
|
||||
response = response[start + 3, end]
|
||||
logging.info(f"fixed answer:\n{pformat(response)}")
|
||||
return response
|
||||
except Exception as err:
|
||||
logging.warning(f"failed to execute a fix for the answer: {repr(err)}")
|
||||
return answer
|
||||
|
||||
Loading…
Reference in New Issue
Block a user