fromenumimportEnumimportopenai_tiny_function_callingclassUnit(Enum):
CELSIUS="celsius"FAHRENHEIT="fahrenheit"defget_current_weather(location: str, unit: Unit=Unit.CELSIUS):
""" Get the current weather in a given location Args: location: The city and state, e.g. San Francisco, CA unit: The temperature unit to use """passdeftest_example():
function=openai_tiny_function_calling.create_function_dict(get_current_weather)
print(function)
assertfunction["name"] =="get_current_weather"assertfunction["description"] =="Get the current weather in a given location"assertfunction["parameters"]["properties"]["location"]["type"] =="string"assertfunction["parameters"]["properties"]["location"]["description"] =="The city and state, e.g. San Francisco, CA"assertfunction["parameters"]["properties"]["unit"]["type"] =="string"assertset(function["parameters"]["properties"]["unit"]["enum"]) == {"celsius", "fahrenheit"}
assertfunction["parameters"]["properties"]["unit"]["description"] =="The temperature unit to use (Default: celsius)"assertset(function["parameters"]["required"]) == {"location"}