Small bugfix to not call OpenAI twice and File Reformat

This commit is contained in:
Pedro Fonseca
2023-09-03 15:13:41 +01:00
parent fcd7483fd9
commit cfff3ee6dd
3 changed files with 34 additions and 12 deletions

View File

@@ -53,7 +53,12 @@ def make_openai_call(model, messages, token_count, fields_to_check, temperature)
frequency_penalty=float(FREQUENCY_PENALTY),
messages=messages
)
if fields_to_check is None:
return result["choices"][0]["message"]["content"]
processed_response = process_response(result["choices"][0]["message"]["content"], fields_to_check[0])
if check_fields(processed_response, fields_to_check) is False and try_count < TRY_LIMIT:
try_count = try_count + 1
return make_openai_call(model, messages, token_count, fields_to_check, temperature)