Get startedGet started for free

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.

This exercise is part of the course

Developing AI Systems with the OpenAI API

View Course

Exercise instructions

  • Define the function 'type' parameter.
  • Define the 'properties' parameters to extract the title and year of publication from research papers.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

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)
Edit and Run Code