Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

fix(ensu): describe images sent without text

setalpc75332587cc6
diff --git a/android/apps/ensu/app/src/main/java/io/ente/ensu/chat/ChatStoreActions.kt b/android/apps/ensu/app/src/main/java/io/ente/ensu/chat/ChatStoreActions.kt
index 23d18b4f17..fb40961c37 100644
--- a/android/apps/ensu/app/src/main/java/io/ente/ensu/chat/ChatStoreActions.kt
+++ b/android/apps/ensu/app/src/main/java/io/ente/ensu/chat/ChatStoreActions.kt
@@ -1873,6 +1873,10 @@ internal class ChatStoreActions(
}
if (imageFiles.isNotEmpty()) {
+ if (builder.isBlank()) {
+ builder.clear()
+ builder.append("Describe the attached images.")
+ }
builder.append("\n\n[")
builder.append(imageFiles.size)
builder.append(" image attachment")
diff --git a/apple/apps/ensu/Ensu/Chat/ChatViewModel.swift b/apple/apps/ensu/Ensu/Chat/ChatViewModel.swift
index d0c5eff0a1..d438e318c0 100644
--- a/apple/apps/ensu/Ensu/Chat/ChatViewModel.swift
+++ b/apple/apps/ensu/Ensu/Chat/ChatViewModel.swift
@@ -2538,6 +2538,9 @@ final class ChatViewModel: ObservableObject {
let imageFiles = images.compactMap { $0.url }
if !imageFiles.isEmpty {
+ if prompt.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
+ prompt = "Describe the attached images."
+ }
let mediaMarker = "<__media__>"
prompt += "\n\n[\(imageFiles.count) image attachment"
if imageFiles.count > 1 { prompt += "s" }
diff --git a/web/apps/ensu/src/pages/chat.tsx b/web/apps/ensu/src/pages/chat.tsx
index 50735d02e4..10d18f20be 100644
--- a/web/apps/ensu/src/pages/chat.tsx
+++ b/web/apps/ensu/src/pages/chat.tsx
@@ -223,6 +223,9 @@ const MAX_IMAGE_ATTACHMENTS_PER_MESSAGE = 2;
const buildPromptWithImages = (text: string, imageCount: number) => {
if (imageCount <= 0) return text;
let prompt = text;
+ if (!prompt.trim()) {
+ prompt = "Describe the attached images.";
+ }
prompt += `\n\n[${imageCount} image attachment${imageCount === 1 ? "" : "s"} provided]`;
for (let index = 0; index < imageCount; index += 1) {
prompt += `\n${MEDIA_MARKER}`;