IniziaInizia gratis

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.

Questo esercizio fa parte del corso

Developing AI Systems with the OpenAI API

Visualizza il corso

Istruzioni dell'esercizio

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

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

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)
Modifica ed esegui il codice