How to call functions with chat models - Basic Concepts
Basic concepts Let's create some function specifications to interface with a hypothetical weather API. We'll pass these function specification to the Chat Completions API in order to generate function arguments that adhere to the specification. functions = [ { 'name': 'get_current_weather', 'description': 'Get the current weather', 'parameters': { 'type': 'object', 'properties': { 'location': { 'type': 'string', 'description': 'The city and state, e.g. San Francisco, CA', }, 'format': { 'type': 'string', 'enum': ['celsius', 'fahrenheit'], 'description': 'The temperature unit to use. Infer this from the users location.', }, }, 'required': ['location', 'format'], }, }, { 'name': 'get_n_day_weather_forecast', 'description': 'Get an N-day weather forecast', 'parameters': { 'type': 'object', 'properties': { 'location': { 'type': 'string', 'description': 'The city and state, e.g. San Francisco, CA', }, 'format': { 'type': 'string', 'enum': ['celsius', 'fahrenheit'], 'description': 'The temperature unit to use. Infer this from the users location.', }, 'num_days': { 'type': 'integer', 'description': 'The number of days to forecast', } }, 'required': ['location', 'format', 'num_days'] }, }, ]