Hello!
I’m trying to extract addresses from a text using a function call.
Since I want all the addresses I decided to go with an array.
I found an example in another post and used it as a template:
{
name: 'get_weather',
description: 'Get weather from given locations and datetimes',
parameters: {
type: 'object',
properties: {
locations: {
type: 'array',
items: {
type: "object",
properties: {
name: { type: "string", description: "Name of location, e.g. San Francisco, CA" },
datetime: { type: "string", description: "Date or time, e.g. today, tomorrow, 2023-06-29" },
}
}
}
},
required: ['locations']
}
}
This is the function I wrote:
functions = [{
"name": "get_addresses",
"description": "Get all unique addresses from a text",
"parameters": {
"type": "object",
"properties": {
"addresses": {
"type": "array",
"description": "The address of a company or building",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of the company or building"
},
"street": {
"type": "string",
"description": "The street name of the building or company"
},
"postcode": {
"type": "string",
"description": "The postcode of the building or company, e.g. 65496, 3824 ME, ..."
},
"city": {
"type": "string",
"description": "The city name of the building or company, e.g. Köln, Kopenhagen, ..."
},
"country_code": {
"type": "string",
"description": "The ISO country code of the building or company, e.g. UK, DE, DK"
}
}
}
},
"required": ["addresses"]
}
}
}]
I can’t see any structural difference between the example and my code, but I always get the following error message:
openai.error.InvalidRequestError: Invalid schema for function ‘get_addresses’: [‘addresses’] is not of type ‘object’, ‘boolean’
What am I missing?
Or is there a better way to extract a list of results altogether?
Best regards
Ralf