Skip to content

Commit

Permalink
Merge pull request #192 from nasa-petal/file_id_fix
Browse files Browse the repository at this point in the history
fixes #191
  • Loading branch information
bruffridge authored Jan 23, 2025
2 parents c8fe99f + 97a27ba commit a5b1de1
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions src/components/AssistantDeepChat.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,31 @@
// logger.debug("Original Request Body:", JSON.stringify(body, null, 2));
// console.log("Original Request Body:", JSON.stringify(body, null, 2));
// Ensure placeholder text is added for file-only requests, or requests with empty message text.
if (
const fileMsg = {
type: "text",
text:
"I just uploaded a file. Ask me what I'd like you to do with it."
}
if ( // an image was uploaded. todo: handle multiple images uploaded at once.
'content' in body &&
Array.isArray(body.content) &&
body.content.length > 0 &&
'image_file' in body.content[0]
) {
if(body.content.length > 1) { // user included a message with the image
fileMsg.text = "The file_id is: " + body.content[0].image_file.file_id;
}
else { //user did not include a message with the image
fileMsg.text += " The file_id is: " + body.content[0].image_file.file_id;
}
body.content.push(fileMsg);
}
else if ( // just a file was uploaded with no text message.
'attachments' in body &&
Array.isArray(body.attachments) &&
body.attachments.length > 0 &&
Expand All @@ -239,13 +262,7 @@
)
) {
// logger.info("Adding placeholder text for file-only request.");
body.content = [
{
type: "text",
text:
"I just uploaded a file. Let me know if you got it and what tools you can use to analyze it. Wait for me to tell you what to do next with it though."
},
];
body.content = [fileMsg];
} else {
// logger.warn("Request body does not contain a valid content structure.");
}
Expand Down

0 comments on commit a5b1de1

Please sign in to comment.