Open AI Chat model is not returning correct result even though receives correct information

  • 1.56.2 (Hosted by n8n Cloud)
  • Database (supabase as vector store and Postgre Chat Memory):
  • n8n EXECUTIONS_PROCESS setting: not sure?
  • Running n8n via n8n cloud:
  • Operating system: Locally? Windows 11/Edge Browser

I am trying to learn this. I have a dev background of 20+ years but am struggling in trying to work out why the Open AI chat model is not returning the correct information even though it is returned correctly from the vector store. I am following this tutorial on youtube (4) This RAG AI Agent with n8n + Supabase is the Real Deal - YouTube and I can insert and update the files and see them in supabase and they ar ebeing correctly retrieved by the “Retrieve Documents” node but when the “Open AI Chat Model1” node just keeps returning “I cant access your documents”.

Here is a picture of what I think the “offending node” is doing. It is admitedly not receving the input in great layout but I dont know how to change that but the content of the files is there (“this contains the meeting notes from 9 September 2024” and “This is the content of the document”)

This is the output of the Supabase Vector Store and as you can see it is finding both documents in the Google folder and returning the contents


[
{
"response": 
[
{
"pageContent": 
"This contains the meeting notes from 9 September 2024",
"metadata": 
{
"loc": 
{
"lines": 
{
"to": 
1,
"from": 
1
}
},
"source": 
"blob",
"file_id": 
"16vGEwtOvPg7QTVOOCv41dl8Jr1xY7s-ksV3_Vf-cDzI",
"blobType": 
"text/plain"
}
},
{
"pageContent": 
"This is the content of the document",
"metadata": 
{
"loc": 
{
"lines": 
{
"to": 
1,
"from": 
1
}
},
"source": 
"blob",
"file_id": 
"1hr_NMh3bUZ0Iw5vG5DjvLyMSMkXkt4YS3cZiQqC-Jqs",
"blobType": 
"text/plain"
}
}
]
}
]

this is the input of the Open AI Chat Model1 and the content is embedded in the messages. It is not ideal and I dont know why it produces the input like this but the content is definately there

[
{
"messages": 
[
"System: Use the following pieces of context to answer the users question. \nIf you don't know the answer, just say that you don't know, don't try to make up an answer.\n----------------\nThis contains the meeting notes from 9 September 2024\n\nThis is the content of the document\nHuman: give me the contents of the Meeting Notes file"
],
"estimatedTokens": 
74,
"options": 
{
"openai_api_key": 
{
"lc": 
1,
"type": 
"secret",
"id": 
[
"OPENAI_API_KEY"
]
},
"model": 
"gpt-4o",
"timeout": 
60000,
"max_retries": 
2,
"configuration": 
{
},
"model_kwargs": 
{
}
}
}
]

this is the output of the Open AI Chat Model1 wher eit says it cannot find specific content


[
{
"response": 
{
"generations": 
[
[
{
"text": 
"The information provided does not include the specific contents of the meeting notes from 9 September 2024. I'm unable to give you the details from that document. If you have any other questions or need further assistance, please let me know.",
"generationInfo": 
{
"finish_reason": 
"stop"
}
}
]
]
},
"tokenUsage": 
{
"completionTokens": 
48,
"promptTokens": 
77,
"totalTokens": 
125
}
}
]

this is the main workflow. Everything seems to work except the Chat Model not outputting the reuslt even though it is found

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hi @Bonso_Fotheringham,

I tried reproducing the issue by re-using the template you’ve pasted in the forum using my own dummy data in Google Drive and it seems to be working without any issues.

What I see from your third screenshot is that your page content seems to be “This contains the meeting notes from 9 September 2024” — could it be that when Open AI Chat Model1 says “it cannot find specific content”, it simply can’t find enough content to give you a detailed answer?

When I tested it out with Google docs only containing minimal text e.g. “This is the content of the document”, the AI model’s output was similar to yours:
CleanShot 2024-09-17 at 13.57.52

Could you try filling your Google docs (or wherever you’re inserting the text from) with more content (AI is great for generating dummy meeting note data too!)

Hope that helps!

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