mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 11:14:04 +00:00
(feat) helpers for supports_function_calling
This commit is contained in:
parent
65a41581b6
commit
2771686124
1 changed files with 48 additions and 0 deletions
|
@ -3729,6 +3729,54 @@ def completion_cost(
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
|
||||||
|
def supports_function_calling(model: str):
|
||||||
|
"""
|
||||||
|
Check if the given model supports function calling and return a boolean value.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
model (str): The model name to be checked.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
bool: True if the model supports function calling, False otherwise.
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
Exception: If the given model is not found in model_prices_and_context_window.json.
|
||||||
|
"""
|
||||||
|
if model in litellm.model_cost:
|
||||||
|
model_info = litellm.model_cost[model]
|
||||||
|
if model_info.get("supports_function_calling", False):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
raise Exception(
|
||||||
|
f"Model not in model_prices_and_context_window.json. You passed model={model}."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def supports_parallel_function_calling(model: str):
|
||||||
|
"""
|
||||||
|
Check if the given model supports parallel function calling and return True if it does, False otherwise.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
model (str): The model to check for support of parallel function calling.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
bool: True if the model supports parallel function calling, False otherwise.
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
Exception: If the model is not found in the model_cost dictionary.
|
||||||
|
"""
|
||||||
|
if model in litellm.model_cost:
|
||||||
|
model_info = litellm.model_cost[model]
|
||||||
|
if model_info.get("supports_parallel_function_calling", False):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
raise Exception(
|
||||||
|
f"Model not in model_prices_and_context_window.json. You passed model={model}."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
####### HELPER FUNCTIONS ################
|
####### HELPER FUNCTIONS ################
|
||||||
def register_model(model_cost: Union[str, dict]):
|
def register_model(model_cost: Union[str, dict]):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue