diff --git a/litellm/utils.py b/litellm/utils.py index 94d1040b99..1106d2fec9 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -3729,6 +3729,54 @@ def completion_cost( 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 ################ def register_model(model_cost: Union[str, dict]): """