ChatGPT Transform a Text to Structured Data Objects is messing with me
I am trying to use the function as stated above to give me structured data back, but it keeps giving me the error of: “[400] Invalid schema for function ‘makeParseRawText’: [{‘name’: ‘Full_Name’, ‘type’: ‘string’, ‘isRequired’: False, ‘description’: ‘This is a persons name’}, {‘name’: ‘Email’, ‘type’: ‘string’, ‘isRequired’: False, ‘description’: ‘This is a persons email’}, {‘name’: ‘Phone_number’, ‘type’: ‘string’, ‘isRequired’: False, ‘description’: ‘This is persons phone number’}] is not of type ‘object’”
Currently the object is set to contain a Full_Name, Email and Phone_Number
It can easily read through the text and find all and even more sources when i dont use objects, it had worked perfect and finding all information and being able to list it. How should i input an object in this?
Hey @Malthe_Aarestrup
I was doing a similar case recently and done the same thing with a simple ChatGPT prompt as well in Completion model.
i.e. Return the following text in JSON key value pair where the keys are Name, Email and Phone_number etc.
It will return you proper JSON structure or the desired data structure
1 Like
Hi @Malthe_Aarestrup, this module is an abstraction of the OpenAI function calling.
While I like the setup generally, I do think it’s lacking the correct setup for arrays. If you do the API with code, you can ask for an array and define the items (name, email, phone).
Is it possible that there is more than one contact in the input? So you’d ideally receive an array of contacts?
Best,
Richard
2 Likes
Hey Manish.
I am fairly new to make and thought about using it as a JSON type, is it easy to translate that into an iterator that goes through each so i can for example create 6-7 contacts?
Thanks for the answer and interest!
Hi Richard
I thought as much, and yes, the main purpose of this is to find the relevant people, thus having the option for more than one.
I’ve tried various iterations of allowing it to have an array, but sadly there is only an array of text/number option, not an array of objects. Maybe i simply need to the route as Manish suggested above and do ‘JSON’ + an iterator instead.
My main purpose for these contacts are to in v.1 create a text with each person listed and in v.2 depending on data quality create an object in a CRM for each person found.
Thanks for the answer and interest!
You can still use the Make an API call Module
Ask GPT to come up with the structure…
2 Likes
I’ve not tried it myself, but it looks to me like you need to specify the Data Type
in the Structured Data Definition as Array
rather than Object
.
Note the comment under the Data Type
field:
An appropriate data type of the parameter. Array should be used when multiple occurrences of a similar data type may take place.
2 Likes
Hey @DavidGurr_Make, yes exactly but then it should be possible to specify the items of an array. Otherwise there would be just an array.
So currently it would work something like this
[„firstName lastName zipCode“, „firstName2 lastName2 zipCode2“] which would work but doesn’t really help.
Instead the result should be
[{firstName: XYZ, lastName: ABC, zipCode: GHI},{object2},…]
Or alternatively arrays inside the array. But it’s not possible to do that in the module. Through an API call it is possible though
2 Likes
Ah I see, the UI doesn’t seem to allow Arrays of Objects. Let me check with our Apps team …
3 Likes
Hi David, that would be amazing to have as well!
Hi Richard, when i have the time i might just do the Json, Array and Iterator Solution all though an API call would be cool as well!
It seems that when OpenAI’s Text to Structured Data API was first released it didn’t support an array of objects - but it now does.
I’ve raised a request to add this to the UI. As there is a workaround (see below) it may be a couple of months before this is implemented.
Our devs provided the following code for use in the Make an API Call
module to achieve the same result:
{
"model": "gpt-3.5-turbo",
"messages": [
{
"name": "MakeUser",
"role": "user",
"content": "Here is a list of people and their details. You need to retrieve full name, email and phone number for each of them. Alice Johnson. Email: alice.johnson@email.com; Phone: 555-123-4567. Michael Rodriguez. Email: michael.rodriguez@email.com; Phone: 555-234-5678. Emily Davis. Email: emily.davis@email.com; Phone: 555-345-6789. Christopher Patel. Email: chris.patel@email.com; Phone: 555-456-7890. Olivia Smith. Email: olivia.smith@email.com; Phone: 555-567-8901"
}
],
"functions": [
{
"name": "makeParseRawText",
"parameters": {
"type": "object",
"properties": {
"people": {
"name": "people",
"type": "array",
"description": "Array of people containing full name, email and phone number",
"items": {
"$ref": "#/$defs/person"
}
}
},
"$defs": {
"person": {
"type": "object",
"required": [ "fullName", "email", "phone" ],
"properties": {
"fullName": {
"type": "string",
"description": "Person's name."
},
"email": {
"type": "string",
"description": "Person's email."
},
"phone": {
"type": "string",
"description": "Person's phone number."
}
}
}
},
"required": [
"people"
]
},
"description": "Get a list of personal details for each person."
}
],
"function_call": {
"name": "makeParseRawText"
}
}
4 Likes
Use this option and parse the JSON.
1 Like
FYI, the feature request on this has now been implemented.
You should now be able to request an array of objects as a result of the transformation, without needing to use the Make an API Call
module!
3 Likes