I'm currently developing an app that enables users to interact with AI by asking questions related to the uploaded PDF file. However, I've encountered a problem while interacting with AI on the client side - I keep receiving the error 'TypeError: messagesRef.current.concat is not a function.' This issue has been difficult for me to pinpoint within my code, and I'm struggling to identify the root cause.
To address this issue, I attempted changing the line initialMessages: data || [],
to
initialMessages: Array.isArray(data) ? data : [],
. While this alteration resolved the error, it introduced another problem where messages from the AI and user questions inputted through the client weren't being stored in the database. Despite adding console.log statements throughout my codebase to detect any potential errors preventing saving, everything appears to be set up correctly. The databases utilized are NeonDB and DrizzleORM.
ChatComponent.tsx:
"implementation pending";
/api/chat:
"implementation pending"
MessageList.tsx:
"implementation pending"
/api/get-messages:
"implementation pending"
schema.ts:
"implementation pending"
context.ts:
"implementation pending"