Parallel function calling
After extracting the data from customers' reviews for the marketing team, the company you're working for asks you if there's a way to generate a response to the customer that they can post on their review platform. You decide to use parallel function calling to apply both functions and generate data as well as the responses. You use a function named reply_to_review
and ask to return the review reply as a reply
property.
In this exercise, the get_response()
function, messages
and function_definition
variable have been preloaded. The messages
already contain the user's review, and function_definition
contains the function asking to extract structured data.
This exercise is part of the course
Developing AI Systems with the OpenAI API
Exercise instructions
- Append to the function definition to return the additional message responding to the customer review: the function should have
name
,description
andparameters
specified, and the parameters should betype
andproperties
. - Print the response.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
client = OpenAI(api_key="")
# Append the second function
function_definition.append({'type': 'function', 'function':{'name': ____, ____, ____: {'type': ____, 'properties': {'reply': {____}}}}})
response = get_response(messages, function_definition)
# Print the response
____