Building a function dictionary
You are working on a research project where you need to extract key information from a collection of scientific research papers. The goal is to create a summary of key information from the papers you are given, that includes the title and year of publication. To compile this, you decide to use the OpenAI API with function calling to extract the key information.
The get_response() function and messages, containing the text of the research paper, have been preloaded. The function_definition variable has also partially been filled already.
Deze oefening maakt deel uit van de cursus
Developing AI Systems with the OpenAI API
Oefeninstructies
- Define the function
'type'parameter. - Define the
'properties'parameters to extract the title and year of publication from research papers.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
client = OpenAI(api_key="")
# Define the function parameter type
function_definition[0]['function']['parameters']['type'] = ____
# Define the function properties
function_definition[0]['function']['parameters']['properties'] = ____
response = get_response(messages, function_definition)
print(response)