Kwargs in function call for generic functions

I am finetuning gpt3 model to search for product and restaurants.

def get_products(
    product_name: str = None,
    restaurant_name: str = None,
    category: str = None,
    rating: List[float] = [0, 5],
    price: List[float] = [0, 9999999],
    sort_keys: List[str] = [],
    sort_values: List[str] = [],
    lang: str = "en",
):
    """
    A function that can give the list of products meal/food/menu items that match with the user's query.

    :param product_name: The complete name of the product or meal item
    :param restaurant_name: The name of the restaurant or food location
    :param category: The category of the product
    :param rating: the tuple rating of the product, (lower_bound, upper_bound). Good/average rating (3.5,5.0), top/best/high/excellent rating (4.0,5.0)
    :param price: the tuple price of the product, (lower_bound, upper_bound).
    :param sort_keys: the keys on which the results to be sorted, must be in (rating, price, no_of_orders)
    :param sort_values: the values of the sort keys, must be in (asc, desc), with same index as sort keys
    :param lang: the language of the parameters, must be in (en, ar)
    """
    pass

def get_restaurants(
    restaurant_name: str = None,
    category_cuisine: str = None,
    rating: List[float] = [0, 5],
    sort_keys: List[str] = [],
    sort_values: List[str] = [],
    lang: str = "en",
):
    """
    A function that can give the list of restaurants/eating places that match with the user's query.

    :param restaurant_name: The name of the restaurant or food location
    :param category_cuisine: The category or cuisine of the restaurant
    :param rating: the tuple rating of the restaurant, (lower_bound, upper_bound). Good/average rating (3.5,5.0), top/best/high/excellent rating (4.0,5.0)
    :param sort_keys: the keys on which the results to be sorted, should be in (rating, no_of_orders)
    :param sort_values: the values of the sort keys, should be in (asc, desc)
    :param lang: the language of the parameters, must be in (en, ar)
    """
    pass

However I would like to make my function more generic that in future if there is an addition of another operations such as recommendation or other parameters such as size, calories, serving etc.

def perform_action(entity: str, operation: str, **kwargs):
    """
    A generalized function to perform actions on different entities.

    :param entity: The entity on which the action will be performed (e.g., "product", "restaurant", etc.)
    :param operation: The operation to perform (e.g., "search", "prepare", "recommend", etc.)
    :param kwargs: Additional keyword arguments representing attributes specific to the entity
    """
    if entity == "product":
        if operation == "search":
            # Implement product search functionality using kwargs
            product_name = kwargs.get("product_name")
            restaurant_name = kwargs.get("restaurant_name")
            category = kwargs.get("category")
            rating = kwargs.get("rating", [0, 5])
            price = kwargs.get("price", [0, 9999999])
            sort_keys = kwargs.get("sort_keys", [])
            sort_values = kwargs.get("sort_values", [])
            lang = kwargs.get("lang", "en")
            # Implement search logic here
            pass
    elif entity == "restaurant":
        if operation == "search":
            # Implement restaurant search functionality using kwargs
            restaurant_name = kwargs.get("restaurant_name")
            category_cuisine = kwargs.get("category_cuisine")
            rating = kwargs.get("rating", [0, 5])
            sort_keys = kwargs.get("sort_keys", [])
            sort_values = kwargs.get("sort_values", [])
            lang = kwargs.get("lang", "en")
            # Implement search logic here
            pass
    # Add more elif conditions for other entities and operations as needed
    else:
        print("Unsupported entity or operation.")

Is there any proper api way to include kwargs and to define the allowed parameters so the model can understand better?

In my experience there are two sides to the (Assistant) function calling: the parameters that the Assistant will provide you and the output you give back to the Assistant.

For the input you must define everything the definition of the function, including description, the parameter type and you will have to share which parameters are required.
You CAN use this template as a guideline for what you will OUTPUT as well - but you DONT HAVE TO. Ie you can output whatever information you want in the JSON that you return on a function call. If you name your parameters smart (ie descriptive) the Assistant will deal with whatever output it gets pretty smart (in my experience).

So for you case, if I understand correctly you CAN in the future provide more output (and simply update the prompt to understnad or handle it better) without needed to update the function template(s). If you require different (or more) input from the Assistant when calling your function that WILL have to be done updating the function definition.