# OpenAI Integration - Answer question about a table isnt' work properly

**URL:** <https://community.glideapps.com/t/openai-integration-answer-question-about-a-table-isnt-work-properly/75916>\
**Category:** Ask for Help\
**Created:** [August 27, 2024, 4:29pm UTC](https://community.glideapps.com/t/openai-integration-answer-question-about-a-table-isnt-work-properly/75916 "2024-08-27T16:29:58Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafael\_Salla\_Paulilo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/rafael_salla_paulilo/32/71453_2.png) [@Rafael\_Salla\_Paulilo](https://community.glideapps.com/u/Rafael_Salla_Paulilo)\
**Post date:** [August 27, 2024, 4:29pm UTC](https://community.glideapps.com/t/openai-integration-answer-question-about-a-table-isnt-work-properly/75916/1 "2024-08-27T16:29:58Z")

</div>

I’m trying to use the OpenAI integration but I have two problems:

1. The answers aren`t correct. I have a simple table of several events and I want that the AI select them according to question: Type, Local, date etc.
2. The answers are truncated and doens’t show the entire answer.

---

<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:** [August 27, 2024, 6:20pm UTC](https://community.glideapps.com/t/openai-integration-answer-question-about-a-table-isnt-work-properly/75916/2 "2024-08-27T18:20:47Z")

</div>

Can you grab a screenshot showing us how you’ve configured it?

---

<div class="post-metadata">

**Author:** ![Rafael\_Salla\_Paulilo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/rafael_salla_paulilo/32/71453_2.png) [@Rafael\_Salla\_Paulilo](https://community.glideapps.com/u/Rafael_Salla_Paulilo)\
**Post date:** [August 27, 2024, 9:00pm UTC](https://community.glideapps.com/t/openai-integration-answer-question-about-a-table-isnt-work-properly/75916/3 "2024-08-27T21:00:41Z")

</div>

![Captura de tela 27.08.2024 às 17.33.53 PM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/f/6/f6464d3ba4ed9d2753366091aee9a277395a9f54.jpeg)  
 ![Captura de tela 27.08.2024 às 17.34.03 PM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/1/e/1ea40b559493a0c8b5c10fc908e1352fdf00f778.jpeg)  
My app is in portuguese and the translation to the app’s text is:  
Use AI to search for Event

What kind of experience do you seek in Perdizes?  
Please show me all the events for next weekend.

Summer Breeze 9  
Location: Latin America Memorial  
Type: Festival  
Date(s): 04/26/24, 04/27/24, 04/28/24  
Time: From 11:00 am to 9:30 pm

Summer 9  
Location: Cacilda Becker Theater  
Type: Theater  
Date(s): 05/21/24  
Time: 9:00 pm

The translation for the “Aditional Context” is:  
_The Source Table contains the event schedule and its columns hold the event information, such as: name, description, event type, location, as well as times, days of the week, and dates on which these events will be held. It also indicates whether the event is free and/or for children._

_The output should be ordered by the event start date and formatted as follows:_

- **Event Name** , should be in bold
- **Location:** Event Location
- **Type:** Event Type
- **Date(s):** Dates in DD/MM/YY format
- ️ **Time:** Only the session time\*

_The output should only include events with dates after today._

---

<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:** [August 28, 2024, 12:42am UTC](https://community.glideapps.com/t/openai-integration-answer-question-about-a-table-isnt-work-properly/75916/4 "2024-08-28T00:42:41Z")

</div>

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/5/3/53acff9b1bfe837e6d418c862d258152b094ad8c.jpeg)

So is this a sample answer that OpenAI gave you?

---

<div class="post-metadata">

**Author:** ![Rafael\_Salla\_Paulilo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/rafael_salla_paulilo/32/71453_2.png) [@Rafael\_Salla\_Paulilo](https://community.glideapps.com/u/Rafael_Salla_Paulilo)\
**Post date:** [August 28, 2024, 10:06am UTC](https://community.glideapps.com/t/openai-integration-answer-question-about-a-table-isnt-work-properly/75916/5 "2024-08-28T10:06:40Z")

</div>

Yes. See that the dates are wrong because these are past events and, in this case, they didn’t trunced but show only two events but thera are much more.

---

<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:** [August 28, 2024, 11:41am UTC](https://community.glideapps.com/t/openai-integration-answer-question-about-a-table-isnt-work-properly/75916/6 "2024-08-28T11:41:15Z")

</div>

I think that feature is not suited for data aggregation. They are likely to reference only X most related rows from your table, not the whole set, and then you face hallucinations like you have here.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/f/5/f58e8e5b22a5424c5b1c4c07c072cf84c45a6a19.png)

If you can ingest the whole table’s data into the prompt, then it would make more sense.

---

<div class="post-metadata">

**Author:** ![Rafael\_Salla\_Paulilo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/rafael_salla_paulilo/32/71453_2.png) [@Rafael\_Salla\_Paulilo](https://community.glideapps.com/u/Rafael_Salla_Paulilo)\
**Post date:** [August 28, 2024, 1:04pm UTC](https://community.glideapps.com/t/openai-integration-answer-question-about-a-table-isnt-work-properly/75916/7 "2024-08-28T13:04:19Z")

</div>

> [@ThinhDinh](#):
>
> If you can ingest the whole table’s data into the prompt, then it would make more sense.

Sorry, @ThinhDinh! I didn’t understand how to do this. Please, could you give me a example?

---

<div class="post-metadata">

**Author:** ![Eric\_Penn](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/eric_penn/32/73888_2.png) [@Eric\_Penn](https://community.glideapps.com/u/Eric_Penn)\
**Post date:** [August 28, 2024, 1:19pm UTC](https://community.glideapps.com/t/openai-integration-answer-question-about-a-table-isnt-work-properly/75916/8 "2024-08-28T13:19:37Z")

</div>

One way to do it could be to add a JSON template column in your data table and fill in the fields for the search.

Then from the user profile (or a one row table) add a joined list column and target the JSON template.

Finally use the joined list in a regular open AI request instead of the Answer a question about a table one.

Of course there’s a limit to how much data you can send. If your flow permits maybe you could add some custom filters to limit the number of rows in your joined list/ prompt

---

<div class="post-metadata">

**Author:** ![Rafael\_Salla\_Paulilo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/rafael_salla_paulilo/32/71453_2.png) [@Rafael\_Salla\_Paulilo](https://community.glideapps.com/u/Rafael_Salla_Paulilo)\
**Post date:** [August 28, 2024, 2:41pm UTC](https://community.glideapps.com/t/openai-integration-answer-question-about-a-table-isnt-work-properly/75916/9 "2024-08-28T14:41:03Z")

</div>

To be honest, I have no idea haw to use JSON. I’ll try to find a tutorial.

---

<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:** [August 28, 2024, 2:45pm UTC](https://community.glideapps.com/t/openai-integration-answer-question-about-a-table-isnt-work-properly/75916/10 "2024-08-28T14:45:24Z")

</div>

Adding to the comments above:

There’s a character limit with Open AI’s API, so even if you try to cram everything in a single payload, you’re capped by the API capacity.

@Rafael_Salla_Paulilo – We have an intro to JSON post on the Glide blog. You might find it useful?

> **[Intro to JSON: The Internet’s Standard Data Format | Glide Blog](https://www.glideapps.com/blog/what-is-json)**
>
> Dive into the human-readable data format that’s used to store and communicate data across the web

---

<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:** [August 28, 2024, 2:45pm UTC](https://community.glideapps.com/t/openai-integration-answer-question-about-a-table-isnt-work-properly/75916/11 "2024-08-28T14:45:40Z")

</div>

> [@Eric\_Penn](#):
>
> One way to do it could be to add a JSON template column in your data table and fill in the fields for the search.

Yup, this is what I meant when I say “ingest the whole table”. That’s what I do for a recent app as well when “Answer question about a table” doesn’t work.

The alternative is perhaps training your own GPT, if you have the right structure for it. They are offering 1 million free tokens per day.

[https://openai.com/index/gpt-4o-fine-tuning/](https://openai.com/index/gpt-4o-fine-tuning/)

---

<div class="post-metadata">

**Author:** ![Rafael\_Salla\_Paulilo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/rafael_salla_paulilo/32/71453_2.png) [@Rafael\_Salla\_Paulilo](https://community.glideapps.com/u/Rafael_Salla_Paulilo)\
**Post date:** [August 28, 2024, 9:33pm UTC](https://community.glideapps.com/t/openai-integration-answer-question-about-a-table-isnt-work-properly/75916/12 "2024-08-28T21:33:20Z")

</div>

Thanks! I’ll try.

---

<div class="post-metadata">

**Author:** ![Rafael\_Salla\_Paulilo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/rafael_salla_paulilo/32/71453_2.png) [@Rafael\_Salla\_Paulilo](https://community.glideapps.com/u/Rafael_Salla_Paulilo)\
**Post date:** [August 29, 2024, 1:05pm UTC](https://community.glideapps.com/t/openai-integration-answer-question-about-a-table-isnt-work-properly/75916/13 "2024-08-29T13:05:51Z")

</div>

I solved the problem of truncated text! If you don’t put anything in “Maximum Lenght”, they assume 255 tokens (I guess). So, the answer truncee. I put 2.000 and works perfectly.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/system/32/53398_2.png) [@system](https://community.glideapps.com/u/system)\
**Post date:** [September 5, 2024, 7:28pm UTC](https://community.glideapps.com/t/openai-integration-answer-question-about-a-table-isnt-work-properly/75916/14 "2024-09-05T19:28:55Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
