-
Notifications
You must be signed in to change notification settings - Fork 99
Open
Description
Looks like chatMessages is not an array for map(). Anyone know what happened to me?
error message: App.jsx Uncaught (in promise) TypeError: chatMessages.map is not a function
error code:
async function processMessageToChatGPT(chatMessages) { // messages is an array of messages
// Format messages for chatGPT API
// API is expecting objects in format of { role: "user" or "assistant", "content": "message here"}
// So we need to reformat
let apiMessages = chatMessages.map((messageObject) => {
let role = "";
if (messageObject.sender === "ChatGPT") {
role = "assistant";
} else {
role = "user";
}
return { role: role, content: messageObject.message}
});
Metadata
Metadata
Assignees
Labels
No labels