Fix function_calling_llm support for custom models #3709
+91
−41
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix function_calling_llm support for custom models
Summary
Fixes #3708 where
function_calling_llmdid not work for custom models not in litellm's supported models list.The issue occurred because when a user set
function_calling_llmto use a custom model (e.g., a company's proprietary model through a custom provider), the framework would check if the model supports function calling usinglitellm.utils.supports_function_calling(). For models not in litellm's list, this check would returnFalse, preventing function calling from being used even though the model actually supported it.Changes:
supports_function_calling()method that returnsTrueby default (similar to existingsupports_stop_words()method)supports_function_callingparameter to allow explicit override of litellm's auto-detectionUsage examples:
Review & Testing Checklist for Human
uv run pytest tests/to ensure no regressionsfunction_calling_llmworks with the newsupports_function_calling=Trueparametersupports_function_calling()still work correctlyTest Plan
LLM(model="company/custom-model", supports_function_calling=True)function_calling_llmon an agentNotes
None, which uses litellm's check)