Glide AI Generate text issue

Hello everyone, I’m trying to have Glide AI generate a JSON string based on the reading of a transfer receipt.

The instruction I provide is this:

Screenshot_1

The problem is that, with some receipts, it reads well, but with others, it forms a seemingly broken JSON string, and therefore, when I try to extract each piece of data through a JSON Query column, they stop working.

Malformed JSON generated by the AI.:
Screenshot_2

Is there something wrong with the instructions I’m providing?

Maybe tell it not to include back ticks or a code block???

I have talked with Bob about this, since OpenAI does have an option to force returning JSON, if Glide can do it, give us a checkbox to force returning JSON or not.

https://platform.openai.com/docs/guides/text-generation/json-mode

cc @NoCodeAndy

2 Likes

I had the same issue. I solved it by adding the following text to my prompt:

Provide the JSON object as a direct response without any additional comments or annotations - only output the JSON object and do not include ```json

example:

4 Likes

@Simon_Hill - Thanks for sharing the workaround!

@ThinhDinh - Good suggestion. I’ve shared it with the dev team.

1 Like

Text to JSON does exactly this. Why not use it?

I found the chat to text integration in which you pass an image along with the prompt tended to generate the issue above.

I tried a custom action involving a number of steps. In step 1 I ran the chat to text and returned some text, then in step 2 I ran the text to JSON. This led to issues with blank results.

The significant delays in running step 1 seemed difficult to manage even after inserting a ‘wait with condition’ action in-between.

In the end the solution I tested above uses 1 step, avoids the delay shenanigans and works ok.

1 Like

@david because Each run uses 1 update and JSON Query doesn’t
@Simon_Hill Thanks, I’m going to try this recommendation along with another one that was sent to me by private message

Text to JSON is Generate Text in JSON output mode.

Say for Simon’s use case above, would you consider supporting image as an input for the Text to JSON action/column? I think the only action/column where image is supported is “Complete chat” in OpenAI.

2 Likes

Generate Text and Text to JSON both use 1 update.

This is what I use for my receipts.

Upload Image
Document to Text pointed to Upload Image (5 Updates)
Text to JSON pointed to Document to Text with all defined objects (1 Update)
1 Query JSON per object pointed to Document to Text to extract the specific information (No Updates)

I tried Image to Text which is only 1 update, but found it less consistent.

2 Likes