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?