# Glide AI Generate text issue

**URL:** https://community.glideapps.com/t/glide-ai-generate-text-issue/70325
**Category:** Ask for Help
**Created:** [January 31, 2024, 2:17pm UTC](https://community.glideapps.com/t/glide-ai-generate-text-issue/70325 "2024-01-31T14:17:09Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Rimatcom](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/rimatcom/32/32285_2.png) [@Rimatcom](https://community.glideapps.com/u/Rimatcom)
#### Post date: [January 31, 2024, 2:17pm UTC](https://community.glideapps.com/t/glide-ai-generate-text-issue/70325/1 "2024-01-31T14:17:09Z")

</div>

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](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/0/2/0273051cc8cd2bd089ebdc289bc96fc81bbe5a5c.png)

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](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/6/0/60a45babc2280ca1e2a562fffe01e1cc27eaa497.png)

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

---

<div class="post-metadata">

### Author: ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)
#### Post date: [January 31, 2024, 2:24pm UTC](https://community.glideapps.com/t/glide-ai-generate-text-issue/70325/2 "2024-01-31T14:24:11Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)
#### Post date: [January 31, 2024, 3:05pm UTC](https://community.glideapps.com/t/glide-ai-generate-text-issue/70325/3 "2024-01-31T15:05:27Z")

</div>

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](https://platform.openai.com/docs/guides/text-generation/json-mode)

cc @NoCodeAndy

---

<div class="post-metadata">

### Author: ![Simon\_Hill](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/simon_hill/32/94730_2.png) [@Simon\_Hill](https://community.glideapps.com/u/Simon_Hill)
#### Post date: [January 31, 2024, 3:06pm UTC](https://community.glideapps.com/t/glide-ai-generate-text-issue/70325/4 "2024-01-31T15:06:57Z")

</div>

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:

> [@Cool use of AI for analyzing a meal](https://community.glideapps.com/t/cool-use-of-ai-for-analyzing-a-meal/69609):
>
> Just sharing a little feature that makes use of the ‘Complete Chat’ AI integration. The App sends an image of some food along with a prompt that asks for a descriptive title, visible ingredients and then an estimate of some nutritional info. I ask the output to be in JSON so that I can easily handle the data. I’m impressed with how meticulous it is at identifying ingredients… and for this use case the data is accurate enough. Nice job Glide! [[Glide AI integration - Analyze my meal] ](https://www.youtube.com/watch?v=WTQrBntWSFo) …

---

<div class="post-metadata">

### Author: ![NoCodeAndy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/nocodeandy/32/62530_2.png) [@NoCodeAndy](https://community.glideapps.com/u/NoCodeAndy)
#### Post date: [January 31, 2024, 4:42pm UTC](https://community.glideapps.com/t/glide-ai-generate-text-issue/70325/5 "2024-01-31T16:42:49Z")

</div>

@Simon_Hill - Thanks for sharing the workaround!

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

---

<div class="post-metadata">

### Author: ![david](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/david/32/62831_2.png) [@david](https://community.glideapps.com/u/david)
#### Post date: [January 31, 2024, 4:58pm UTC](https://community.glideapps.com/t/glide-ai-generate-text-issue/70325/6 "2024-01-31T16:58:44Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Simon\_Hill](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/simon_hill/32/94730_2.png) [@Simon\_Hill](https://community.glideapps.com/u/Simon_Hill)
#### Post date: [January 31, 2024, 7:07pm UTC](https://community.glideapps.com/t/glide-ai-generate-text-issue/70325/7 "2024-01-31T19:07:51Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Rimatcom](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/rimatcom/32/32285_2.png) [@Rimatcom](https://community.glideapps.com/u/Rimatcom)
#### Post date: [January 31, 2024, 11:26pm UTC](https://community.glideapps.com/t/glide-ai-generate-text-issue/70325/8 "2024-01-31T23:26:49Z")

</div>

@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

---

<div class="post-metadata">

### Author: ![david](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/david/32/62831_2.png) [@david](https://community.glideapps.com/u/david)
#### Post date: [January 31, 2024, 11:41pm UTC](https://community.glideapps.com/t/glide-ai-generate-text-issue/70325/9 "2024-01-31T23:41:15Z")

</div>

Text to JSON is Generate Text in JSON output mode.

---

<div class="post-metadata">

### Author: ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)
#### Post date: [January 31, 2024, 11:53pm UTC](https://community.glideapps.com/t/glide-ai-generate-text-issue/70325/10 "2024-01-31T23:53:32Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Joe\_Gabriele](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/joe_gabriele/32/57595_2.png) [@Joe\_Gabriele](https://community.glideapps.com/u/Joe_Gabriele)
#### Post date: [February 1, 2024, 3:35am UTC](https://community.glideapps.com/t/glide-ai-generate-text-issue/70325/11 "2024-02-01T03:35:42Z")

</div>

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.
