forked from phoenix/litellm-mirror
Merge pull request #3439 from phact/patch-3
add_function_to_prompt bug fix
This commit is contained in:
commit
4e7b5aa9d7
2 changed files with 12 additions and 2 deletions
|
@ -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
|
|
@ -4836,7 +4836,7 @@ def get_optional_params(
|
||||||
**kwargs,
|
**kwargs,
|
||||||
):
|
):
|
||||||
# retrieve all parameters passed to the function
|
# retrieve all parameters passed to the function
|
||||||
passed_params = locals()
|
passed_params = locals().copy()
|
||||||
special_params = passed_params.pop("kwargs")
|
special_params = passed_params.pop("kwargs")
|
||||||
for k, v in special_params.items():
|
for k, v in special_params.items():
|
||||||
if k.startswith("aws_") and (
|
if k.startswith("aws_") and (
|
||||||
|
@ -4933,6 +4933,7 @@ def get_optional_params(
|
||||||
and custom_llm_provider != "mistral"
|
and custom_llm_provider != "mistral"
|
||||||
and custom_llm_provider != "anthropic"
|
and custom_llm_provider != "anthropic"
|
||||||
and custom_llm_provider != "cohere_chat"
|
and custom_llm_provider != "cohere_chat"
|
||||||
|
and custom_llm_provider != "cohere"
|
||||||
and custom_llm_provider != "bedrock"
|
and custom_llm_provider != "bedrock"
|
||||||
and custom_llm_provider != "ollama_chat"
|
and custom_llm_provider != "ollama_chat"
|
||||||
):
|
):
|
||||||
|
@ -4957,7 +4958,7 @@ def get_optional_params(
|
||||||
litellm.add_function_to_prompt
|
litellm.add_function_to_prompt
|
||||||
): # if user opts to add it to prompt instead
|
): # if user opts to add it to prompt instead
|
||||||
optional_params["functions_unsupported_model"] = non_default_params.pop(
|
optional_params["functions_unsupported_model"] = non_default_params.pop(
|
||||||
"tools", non_default_params.pop("functions")
|
"tools", non_default_params.pop("functions", None)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
raise UnsupportedParamsError(
|
raise UnsupportedParamsError(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue