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.
Bu egzersiz
Developing AI Systems with the OpenAI API
kursunun bir parçasıdırEgzersiz talimatları
- Define the function
'type'parameter. - Define the
'properties'parameters to extract the title and year of publication from research papers.
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
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)