Description
Problem:
Hello,
I have a chatflow with Retrieval Agent + Pinecone + File loader. When user uploads file via chat embed, everything works fine. File is uploaded, loaded by File loader, auto upsert to Pinecone and then Agent knows context of file.
However, in my case, I need to upload file to conversation via API first. When I call send message and upload base64, it does not work, Pinecone is not updated and Agent does not know anything about the document. There is no error in response on this API call or in LangSmith. I used the upload code from the Flowise docs example so it should work.
My general goal for context:
In our system, we have a lot of dynamic files and I want to make Agent than can retriavel from specific one file that user select. So I cant use some batch upsert of all files at one or something like that. So my idea is that when user want to "chat with file", embed is loaded and inicialised chat and my component send API call with this file automatically, with file I send same info like sessionId, chatId same as embed component. File is uploaded via API and then user can talk to agent about this specific file freshly loaded in Pinecone. I think there is alternative solution to create some other upsert flow where I can upsert single file with some metadata and then connect it to this my original flow, but Idea with api seems more clean and more compact for me.
Code
Api call:
const sendMessage = async (data: any) => {
const response = await fetch(
`${apiHost}/api/v1/prediction/${chatflowid}`,
{
method: "POST",
headers: {"Content-Type": "application/json"},
body: JSON.stringify(data)
}
);
const result = await response.json();
return result;
}
sendMessage({
"question": "",
"chatId": chatId,
"overrideConfig": {
"sessionId": sessionId,
},
"uploads": [
{
"data": "data:application/pdf;base64,JVBERi0xLjcNCiW1tbW1DQoxIDAgb2J........."
"type": 'file',
"name": 'VOP_EN_2023-06-26.pdf',
"mime": 'application/pdf'
}
]
}).then((response) => {
console.log(response);
});
React embed:
<FullPageChat
chatflowid={chatflowid}
apiHost={apiHost}
chatflowConfig={
{
sessionId: sessionId,
vars: {
customerId: chatId
}
}
}
/>
Expected behavior
Works same as manual user upload.
Setup
- Render instance
- Flowise Version 2.1.1
Thank you for your time.