From fb5afd34170fb389f68f1df43c226200000871a5 Mon Sep 17 00:00:00 2001 From: Zvonimir Sabljic Date: Thu, 3 Aug 2023 11:17:48 +0200 Subject: [PATCH] If there is only one function call, force GPT to use it and if there are multiple, use 'auto' --- euclid/utils/llm_connection.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/euclid/utils/llm_connection.py b/euclid/utils/llm_connection.py index d28bb84..2193b95 100644 --- a/euclid/utils/llm_connection.py +++ b/euclid/utils/llm_connection.py @@ -61,7 +61,10 @@ def create_gpt_chat_completion(messages: List[dict], req_type, min_tokens=MIN_TO if function_calls is not None: gpt_data['functions'] = function_calls['definitions'] - gpt_data['function_call'] = { 'name': function_calls['definitions'][0]['name'] } + if len(function_calls['definitions']) > 1: + gpt_data['function_call'] = 'auto' + else: + gpt_data['function_call'] = { 'name': function_calls['definitions'][0]['name'] } try: response = stream_gpt_completion(gpt_data, req_type)