mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-09 00:26:01 +00:00
Merge pull request #3439 from phact/patch-3
add_function_to_prompt bug fix
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
import litellm
|
||||
from litellm import get_optional_params
|
||||
|
||||
litellm.add_function_to_prompt = True
|
||||
optional_params = get_optional_params(
|
||||
tools= [{'type': 'function', 'function': {'description': 'Get the current weather in a given location', 'name': 'get_current_weather', 'parameters': {'type': 'object', 'properties': {'location': {'type': 'string', 'description': 'The city and state, e.g. San Francisco, CA'}, 'unit': {'type': 'string', 'enum': ['celsius', 'fahrenheit']}}, 'required': ['location']}}}],
|
||||
tool_choice= 'auto',
|
||||
)
|
||||
assert optional_params is not None
|
||||
+3
-2
@@ -4836,7 +4836,7 @@ def get_optional_params(
|
||||
**kwargs,
|
||||
):
|
||||
# retrieve all parameters passed to the function
|
||||
passed_params = locals()
|
||||
passed_params = locals().copy()
|
||||
special_params = passed_params.pop("kwargs")
|
||||
for k, v in special_params.items():
|
||||
if k.startswith("aws_") and (
|
||||
@@ -4933,6 +4933,7 @@ def get_optional_params(
|
||||
and custom_llm_provider != "mistral"
|
||||
and custom_llm_provider != "anthropic"
|
||||
and custom_llm_provider != "cohere_chat"
|
||||
and custom_llm_provider != "cohere"
|
||||
and custom_llm_provider != "bedrock"
|
||||
and custom_llm_provider != "ollama_chat"
|
||||
):
|
||||
@@ -4957,7 +4958,7 @@ def get_optional_params(
|
||||
litellm.add_function_to_prompt
|
||||
): # if user opts to add it to prompt instead
|
||||
optional_params["functions_unsupported_model"] = non_default_params.pop(
|
||||
"tools", non_default_params.pop("functions")
|
||||
"tools", non_default_params.pop("functions", None)
|
||||
)
|
||||
else:
|
||||
raise UnsupportedParamsError(
|
||||
|
||||
Reference in New Issue
Block a user