Test fixes in openai_compat

This commit is contained in:
Swapna Lekkala 2025-09-17 16:50:46 -07:00
parent e56a3f266c
commit d60514b57b
7 changed files with 221 additions and 7 deletions

View file

@ -590,6 +590,7 @@ class InferenceRouter(Inference):
async def _nonstream_openai_chat_completion(self, provider: Inference, params: dict) -> OpenAIChatCompletion:
response = await provider.openai_chat_completion(**params)
for choice in response.choices:
# some providers return an empty list for no tool calls in non-streaming responses
# but the OpenAI API returns None. So, set tool_calls to None if it's empty
@ -739,7 +740,6 @@ class InferenceRouter(Inference):
id = None
created = None
choices_data: dict[int, dict[str, Any]] = {}
try:
async for chunk in response:
# Skip None chunks