How to call functions with chat models - SQL Query Example 2
messages.append({'role': 'user', 'content': 'What is the name of the album with the most tracks?'}) chat_response = chat_completion_request(messages, functions) assistant_message = chat_response.json()['choices'][0]['message'] messages.append(assistant_message) if assistant_message.get('function_call'): results = execute_function_call(assistant_message) messages.append({'role': 'function', 'content': results, 'name': assistant_message['function_call']['name']}) pretty_print_conversation(messages)