Skip to content
Transforming Text t...
 
Notifications
Clear all

Transforming Text to Structured Data Objects with ChatGPT

15 Posts
5 Users
0 Reactions
4 Views
Malthe_Aarestrup
(@malthe_aarestrup)
Posts: 5
Active Member
Topic starter
 

ChatGPT: Transforming Text to Structured Data Objects is proving challenging

I'm encountering an issue when attempting to use the function to obtain structured data. It consistently returns the error: "[400] Invalid schema for function ‘callin.ioParseRawText’: [{'name': 'FullName', 'type': 'string', 'isRequired': False, 'description': 'This is a persons name'}, {'name': 'Email', 'type': 'string', 'isRequired': False, 'description': 'This is a persons email'}, {'name': 'Phonenumber', 'type': 'string', 'isRequired': False, 'description': 'This is persons phone number'}] is not of type ‘object’"

Currently, the object is configured to include FullName, Email, and PhoneNumber.

When I don't use objects, it can easily process the text and identify all the required information, even more than expected. It previously worked perfectly, extracting and listing all the data. How should I correctly input an object for this functionality?

 
Posted : 06/11/2023 7:47 pm
ManishMandot
(@manishmandot)
Posts: 11
Active Member
 

Hello there!

I recently worked on a similar scenario and achieved the same result using a straightforward ChatGPT prompt with the Completion model.

For instance, I instructed it to return text in a JSON key-value pair format, with keys such as Name, Email, and Phone_number.

This approach should yield a proper JSON structure or the desired data format.

 
Posted : 07/11/2023 5:44 pm
Richard_Johannes
(@richard_johannes)
Posts: 21
Eminent Member
 

Hi, 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

 
Posted : 08/11/2023 7:05 am
Malthe_Aarestrup
(@malthe_aarestrup)
Posts: 5
Active Member
Topic starter
 

Hello!

I'm relatively new to callin.io and was considering using it with JSON data. Is it straightforward to convert that into an iterator that processes each item, allowing me to, for instance, create 6-7 contacts?

Thanks for your help and interest!

 
Posted : 09/11/2023 7:49 am
Malthe_Aarestrup
(@malthe_aarestrup)
Posts: 5
Active Member
Topic starter
 

Hi Richard

I suspected as much, and yes, the primary goal here is to identify the relevant individuals, which is why having the option for more than one is important.

I've experimented with several ways to allow for an array, but unfortunately, it only supports arrays of text/numbers, not arrays of objects. Perhaps I just need to use the route as Manish suggested earlier and opt for 'JSON' followed by an iterator instead.

My main objectives for these contacts are to, in v.1, create a text message listing each person, and in v.2, depending on data quality, create an object in a CRM for each person identified.

Thanks for your response and for your interest!

 
Posted : 09/11/2023 7:52 am
Richard_Johannes
(@richard_johannes)
Posts: 21
Eminent Member
 

You can still utilize the Make an API call Module

:slight_smile:

Ask GPT to suggest a structure…

:smiley:

 
Posted : 09/11/2023 9:08 am
DavidGurr_Make
(@davidgurr_make)
Posts: 38
Eminent Member
 

I haven't tested this personally, but my understanding is that you should set the Data Type in the Structured Data Definition to Array instead of Object.

Pay attention to the comment associated with the Data Type field:

An appropriate data type for the parameter. Array should be used when multiple instances of a similar data type might occur.

 
Posted : 09/11/2023 9:59 am
Richard_Johannes
(@richard_johannes)
Posts: 21
Eminent Member
 

Hey, yes exactly but then it should be possible to specify the items of an array. Otherwise, there would just be 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.

:slight_smile:

 
Posted : 09/11/2023 12:50 pm
DavidGurr_Make
(@davidgurr_make)
Posts: 38
Eminent Member
 

Ah, I understand. It appears the user interface doesn't support arrays of objects. I'll need to check with our Apps team about this...

 
Posted : 10/11/2023 9:34 am
Malthe_Aarestrup
(@malthe_aarestrup)
Posts: 5
Active Member
Topic starter
 

Hi there, that would be fantastic to have as well!

 
Posted : 10/11/2023 9:48 am
Malthe_Aarestrup
(@malthe_aarestrup)
Posts: 5
Active Member
Topic starter
 

Hi Richard, when I have the time, I might just implement the JSON, Array, and Iterator Solution. Although, an API call would be cool as well!

 
Posted : 10/11/2023 9:49 am
DavidGurr_Make
(@davidgurr_make)
Posts: 38
Eminent Member
 

It appears that when OpenAI’s Text to Structured Data API was initially launched, it did not support an array of objects, but it does now.

I have submitted a request to incorporate this into the UI. Since there's a workaround available (detailed below), it might take a couple of months for this to be implemented.

Our development team provided the following code for use in the callin.io API Call module to achieve the same outcome:

{
    "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"
    }
}
 
Posted : 10/11/2023 11:33 am
SebastianMertens
(@sebastianmertens)
Posts: 8
Active Member
 

Use this option and parse the JSON.

Please provide the rewritten markdown content *it should be in the markdown format.

 
Posted : 25/01/2024 1:53 pm
DavidGurr_Make
(@davidgurr_make)
Posts: 38
Eminent Member
 

Just a heads-up, the feature request for this has now been put into action.

You should now be able to request an array of objects as the output of the transformation, without needing to use the callin.io API Call module!

 
Posted : 29/01/2024 10:20 am
Richard_Johannes
(@richard_johannes)
Posts: 21
Eminent Member
 

Love it!!

 
Posted : 01/02/2024 7:18 am
Share: