How to call functions with chat models - Force Specific Function
Forcing the use of specific functions or no function We can force the model to use a specific function, for example get_n_day_weather_forecast by using the function_call argument. By doing so, we force the model to make assumptions about how to use it. # in this cell we force the model to use get_n_day_weather_forecast messages = [] messages.append({'role': 'system', 'content': 'Don't make assumptions about what values to plug into functions. Ask for clarification if a user request is ambiguous.'}) messages.append({'role': 'user', 'content': 'Give me a weather report for Toronto, Canada.'}) chat_response = chat_completion_request( messages, functions=functions, function_call={'name': 'get_n_day_weather_forecast'} ) chat_response.json()['choices'][0]['message']