@@ -66,28 +66,28 @@ async def request_chat_completion_raw(
6666 if seed and model in SUPPORTS_SEED :
6767 kwargs ["seed" ] = seed
6868
69- if functions and model not in NO_DEVELOPER_ROLE :
70- if model in SUPPORTS_TOOLS :
71- tools = []
72- for func in functions :
73- function = {"type" : "function" , "function" : func , "name" : func ["name" ]}
74- tools .append (function )
75- if tools :
76- kwargs ["tools" ] = tools
77- # If passing tools, make sure the messages payload has no "function_call" key
78- for idx , message in enumerate (messages ):
79- if "function_call" in message :
80- # Remove the message from the payload
81- del kwargs ["messages" ][idx ]
82-
83- else :
84- kwargs ["functions" ] = functions
85- # If passing functions, make sure the messages payload has no tool calls
69+ if functions and model not in NO_DEVELOPER_ROLE :
70+ if model in SUPPORTS_TOOLS :
71+ tools = []
72+ for func in functions :
73+ function = {"type" : "function" , "function" : func , "name" : func ["name" ]}
74+ tools .append (function )
75+ if tools :
76+ kwargs ["tools" ] = tools
77+ # If passing tools, make sure the messages payload has no "function_call" key
8678 for idx , message in enumerate (messages ):
87- if "tool_calls " in message :
79+ if "function_call " in message :
8880 # Remove the message from the payload
8981 del kwargs ["messages" ][idx ]
9082
83+ else :
84+ kwargs ["functions" ] = functions
85+ # If passing functions, make sure the messages payload has no tool calls
86+ for idx , message in enumerate (messages ):
87+ if "tool_calls" in message :
88+ # Remove the message from the payload
89+ del kwargs ["messages" ][idx ]
90+
9191 add_breadcrumb (
9292 category = "api" ,
9393 message = f"Calling request_chat_completion_raw: { model } " ,
0 commit comments