Fix duplicate keyword argument error for acompletion parameter

- Only add acompletion=True to completion_kwargs if not already in kwargs
- Prevents TypeError when functools.partial() receives acompletion twice
- Fixes issue affecting multiple model groups (llama-3-70b, gpt-4o, gemini, etc.)
- More Pythonic approach that respects explicit values in kwargs
This commit is contained in:
Alexsander Hamir 2026-01-22 12:14:06 -08:00
parent ce37729da4
commit fb7f5351ab

View file

@ -555,11 +555,15 @@ async def acompletion(
"safety_identifier": safety_identifier,
"service_tier": service_tier,
"extra_headers": extra_headers,
"acompletion": True, # assuming this is a required parameter
"thinking": thinking,
"web_search_options": web_search_options,
"shared_session": shared_session,
}
# Only add acompletion if not already in kwargs (avoids duplicate keyword argument error)
# acompletion is an internal flag to distinguish async from sync calls
if "acompletion" not in kwargs:
completion_kwargs["acompletion"] = True
if custom_llm_provider is None:
_, custom_llm_provider, _, _ = get_llm_provider(
model=model,