Retool AI Chatbot Providing Incorrect Page Reference

Hi,

I was building a chatbot using the "Chat" component, and the chat is based on a vector I uploaded. In the system prompt, I ask the the bot to return the source of its answer and the page number. Since there is only 1 document in the vector, the source should always be the same.
image

However, when I try typing in the same question multiple times, the page numbers are different every time.


Does anyone know if this is due to the temperature of ChatGPT being to high, or that it's not reading the page numbers correctly? FYI, I am using the Retool managed OpenAI API.

2 Likes

Hi Brian!

It’s a bit tough to tell without seeing your source data. Is there a chance that those page numbers are coming directly from your data anywhere?

If your source data isn’t sensitive, feel free to share the txt file here! If it is, no worries.

Also, which model are you using to make the request (3.5 or 4)?

It might also be worth trying to tweak your prompt as it’s a bit open-ended, giving freedom to mention as many pages as it wants. There is always an element of randomness to the model when it generates the response so it might not think X pages are relevant to a strong enough degree.

Perhaps something like:

Please match the following sourceValue against the data vector data input.
Please respond in the following format:

Source: sourceValue
Page: pageValue

sourceValue is a user input, either a sentence or pargraph.
pageValue is a list of the 2 most relevant pages based on the sourceValue.

And you’d replace sourceValue with the user input value, e.g. {{input.value}}

Let me know if this helps at all!