If there is only one function call, force GPT to use it and if there are multiple, use 'auto'

This commit is contained in:
Zvonimir Sabljic
2023-08-03 11:17:48 +02:00
parent 270f5f9e2a
commit fb5afd3417

View File

@@ -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)