Refactor logic

This commit is contained in:
Peter Wilson 2025-04-23 22:17:58 +01:00
parent a2b836b6a4
commit f517e5953a
No known key found for this signature in database
GPG key ID: 3CECF55EBF09C069

View file

@ -3010,14 +3010,10 @@ def get_optional_params( # noqa: PLR0915
if custom_llm_provider == "ollama":
optional_params["format"] = "json"
litellm.add_function_to_prompt = True # so that main.py adds the function call to the prompt
non_default_params.pop("tool_choice", None) # causes ollama requests to hang
if "tools" in non_default_params:
optional_params[functions_unsupported_model_key] = non_default_params.pop("tools")
non_default_params.pop("tool_choice", None) # causes ollama requests to hang
elif "functions" in non_default_params:
optional_params[functions_unsupported_model_key] = non_default_params.pop("functions")
# Handle all other providers that are not OpenAI-compatible
elif litellm.add_function_to_prompt and (custom_llm_provider not in litellm.openai_compatible_providers):
if litellm.add_function_to_prompt and (custom_llm_provider not in litellm.openai_compatible_providers):
# Attempt to add the supplied function call to the prompt, preferring tools > functions > function_call
function_call_value = non_default_params.pop("tools",
non_default_params.pop("functions",