Skip to content

Suspected logic bug in 'get_optional_params' #10245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

peteski22
Copy link

@peteski22 peteski22 commented Apr 23, 2025

Bug: get_optional_params

Draft PR for potential logic bug in get_optional_params (where the condition custom_llm_provider == "ollama" means it will only ever be ollama).

There was also a case where function_call was the only thing present in the non_default_params but the code didn't check/try to get the value to set it as optional_params["functions_unsupported_model"].

if (
  "functions" in non_default_params
  or "function_call" in non_default_params
  or "tools" in non_default_params
):

The PR adjusts this behaviour such that it is the same regardless of whether custom_llm_provider is ollama or not in the list of openai_compatible_providers.

I had to make a judgement call (so happy to get feedback here) that since the if/elif statement for ollama checked tools then functions, that function_call would come after those two. So the order of precedence is:

tools > functions > function_call

Relevant issues

Refs: #10244

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on (make test-unit)[https://docs.litellm.ai/docs/extras/contributing_code]
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🐛 Bug Fix
🧹 Refactoring

Changes

Copy link

vercel bot commented Apr 23, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
litellm ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 24, 2025 11:25am

Only the if block could ever be reached, elif and else wouldn't due to the logic check going on above: BerriAI@4d2337e#diff-9661b0d8f1d9f48433f2323d1102e963d3098f667f7a25caea79f16fa282f6ddR5269

tweak
@peteski22 peteski22 force-pushed the peteski22/bug/get_optional_params branch from d81bdee to 222eb3f Compare April 24, 2025 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant