From 8a31a83e6e14321a945125f1afd60f9fec3fe67c Mon Sep 17 00:00:00 2001 From: moon Date: Tue, 3 Oct 2023 16:06:54 -0400 Subject: [PATCH] Fix null handling case for functions --- easycompletion/model.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/easycompletion/model.py b/easycompletion/model.py index 009a9c1..59d1056 100644 --- a/easycompletion/model.py +++ b/easycompletion/model.py @@ -196,10 +196,17 @@ def do_chat_completion( response = None for i in range(model_failure_retries): try: - response = openai.ChatCompletion.create( - model=model, messages=messages, temperature=temperature, - functions=functions, function_call=function_call, - ) + if functions is not None: + response = openai.ChatCompletion.create( + model=model, messages=messages, temperature=temperature, + functions=functions, function_call=function_call, + ) + else: + response = openai.ChatCompletion.create( + model=model, messages=messages, temperature=temperature + ) + print('response') + print(response) break except Exception as e: log(f"OpenAI Error: {e}", type="error", log=debug)