@smart-cloud/ai-kit-ui 1.5.13 → 1.5.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smart-cloud/ai-kit-ui",
3
- "version": "1.5.13",
3
+ "version": "1.5.14",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -187,7 +187,9 @@ function createMessageId(prefix: string) {
187
187
  )}`;
188
188
  }
189
189
 
190
- const DEFAULT_MAX_IMAGES = 4;
190
+ // Image input is an explicit opt-in because not every configured frontend
191
+ // model is multimodal. A positive maxImages value is the capability gate.
192
+ const DEFAULT_MAX_IMAGES = 0;
191
193
  const DEFAULT_MAX_BYTES = 5 * 1024 * 1024;
192
194
 
193
195
  const isAbortLike = (e: Error & { code?: string }) => {
@@ -553,6 +555,14 @@ const AiChatbotBase: FC<AiChatbotProps & AiKitShellInjectedProps> = (props) => {
553
555
  [maxImageBytes],
554
556
  );
555
557
 
558
+ const imageAttachmentsEnabled = resolvedMaxImages > 0;
559
+
560
+ useEffect(() => {
561
+ if (!imageAttachmentsEnabled && composerImagesRef.current.length > 0) {
562
+ clearComposerImages();
563
+ }
564
+ }, [clearComposerImages, imageAttachmentsEnabled]);
565
+
556
566
  const hasMessages = messages.length > 0;
557
567
 
558
568
  const isChatBusy = useMemo(
@@ -760,6 +770,11 @@ const AiChatbotBase: FC<AiChatbotProps & AiKitShellInjectedProps> = (props) => {
760
770
 
761
771
  const onPickImages = useCallback(
762
772
  (e: React.ChangeEvent<HTMLInputElement>) => {
773
+ if (!imageAttachmentsEnabled) {
774
+ e.currentTarget.value = "";
775
+ return;
776
+ }
777
+
763
778
  const existing = composerImagesRef.current;
764
779
  const files = Array.from(e.target.files || []);
765
780
  const remaining = Math.max(0, resolvedMaxImages - existing.length);
@@ -797,7 +812,7 @@ const AiChatbotBase: FC<AiChatbotProps & AiKitShellInjectedProps> = (props) => {
797
812
  if (picked.length) setComposerImages((prev) => [...prev, ...picked]);
798
813
  e.currentTarget.value = "";
799
814
  },
800
- [resolvedMaxImages, resolvedMaxBytes],
815
+ [imageAttachmentsEnabled, resolvedMaxImages, resolvedMaxBytes],
801
816
  );
802
817
 
803
818
  const removeImage = useCallback((ix: number) => {
@@ -1144,7 +1159,9 @@ const AiChatbotBase: FC<AiChatbotProps & AiKitShellInjectedProps> = (props) => {
1144
1159
  cancelRequestedRef.current = false;
1145
1160
  setStatusLineError(null);
1146
1161
  setActiveOp("chat");
1147
- const selectedImages = [...composerImagesRef.current];
1162
+ const selectedImages = imageAttachmentsEnabled
1163
+ ? [...composerImagesRef.current]
1164
+ : [];
1148
1165
  const userAttachments = await buildUserAttachments(
1149
1166
  selectedImages,
1150
1167
  selectedAudio,
@@ -1294,6 +1311,7 @@ const AiChatbotBase: FC<AiChatbotProps & AiKitShellInjectedProps> = (props) => {
1294
1311
  labels.emptyResponseLabel,
1295
1312
  labels.unexpectedErrorLabel,
1296
1313
  language,
1314
+ imageAttachmentsEnabled,
1297
1315
  ]);
1298
1316
 
1299
1317
  const handleQuestionKeyDown = useCallback(
@@ -2190,7 +2208,7 @@ const AiChatbotBase: FC<AiChatbotProps & AiKitShellInjectedProps> = (props) => {
2190
2208
  </>
2191
2209
  )}
2192
2210
 
2193
- {resolvedMaxImages > 0 && (
2211
+ {imageAttachmentsEnabled && (
2194
2212
  <>
2195
2213
  <Button
2196
2214
  variant="outline"
@@ -245,6 +245,11 @@ export function getAiRunErrorMessage(
245
245
  details: AiRunErrorDetails,
246
246
  translate: (message: string) => string = (message) => message,
247
247
  ): string {
248
+ if (details.code?.toUpperCase() === "MODEL_CAPABILITY_ERROR") {
249
+ return translate(
250
+ "The configured AI model does not support image attachments. Contact the site administrator.",
251
+ );
252
+ }
248
253
  if (details.classification === "PROVIDER_UNAVAILABLE") {
249
254
  return translate(
250
255
  "Human verification is temporarily unavailable. Please try again.",
package/src/i18n/ar.ts CHANGED
@@ -199,6 +199,8 @@ export const arDict: Record<string, string> = {
199
199
  Thai: "تايلاندي",
200
200
  "The alt text for the image.": "النص البديل للصورة.",
201
201
  "The caption for the image.": "التعليق المصاحب للصورة.",
202
+ "The configured AI model does not support image attachments. Contact the site administrator.":
203
+ "نموذج الذكاء الاصطناعي المُعدّ لا يدعم إرفاق الصور. تواصل مع مسؤول الموقع.",
202
204
  "The description for the image.": "وصف الصورة.",
203
205
  "The excerpt for the post.":
204
206
  "اختياري. ملخص قصير قد يظهر في نتائج البحث والمعاينات.",
package/src/i18n/de.ts CHANGED
@@ -199,6 +199,8 @@ export const deDict: Record<string, string> = {
199
199
  Thai: "Thailändisch",
200
200
  "The alt text for the image.": "Alt-Text für das Bild.",
201
201
  "The caption for the image.": "Bildunterschrift für das Bild.",
202
+ "The configured AI model does not support image attachments. Contact the site administrator.":
203
+ "Das konfigurierte KI-Modell unterstützt keine Bildanhänge. Wenden Sie sich an den Website-Administrator.",
202
204
  "The description for the image.": "Beschreibung für das Bild.",
203
205
  "The excerpt for the post.":
204
206
  "Kurzbeschreibung/Auszug für den Beitrag (kann in Suchergebnissen/Previews erscheinen).",
package/src/i18n/en.ts CHANGED
@@ -213,6 +213,8 @@ export const enDict: Record<string, string> = {
213
213
  Thai: "Thai",
214
214
  "The alt text for the image.": "The alt text for the image.",
215
215
  "The caption for the image.": "The caption for the image.",
216
+ "The configured AI model does not support image attachments. Contact the site administrator.":
217
+ "The configured AI model does not support image attachments. Contact the site administrator.",
216
218
  "The description for the image.": "The description for the image.",
217
219
  "The excerpt for the post.":
218
220
  "Optional. A short summary that may appear in search results and previews.",
package/src/i18n/es.ts CHANGED
@@ -201,6 +201,8 @@ export const esDict: Record<string, string> = {
201
201
  Thai: "tailandés",
202
202
  "The alt text for the image.": "El texto alternativo de la imagen.",
203
203
  "The caption for the image.": "El título de la imagen.",
204
+ "The configured AI model does not support image attachments. Contact the site administrator.":
205
+ "El modelo de IA configurado no admite archivos adjuntos de imagen. Contacta con el administrador del sitio.",
204
206
  "The description for the image.": "La descripción de la imagen.",
205
207
  "The excerpt for the post.":
206
208
  "Opcional. Un resumen breve que puede mostrarse en los resultados de búsqueda y en las vistas previas.",
package/src/i18n/fr.ts CHANGED
@@ -201,6 +201,8 @@ export const frDict: Record<string, string> = {
201
201
  Thai: "thaïlandais",
202
202
  "The alt text for the image.": "Texte alternatif de l'image.",
203
203
  "The caption for the image.": "Légende de l'image.",
204
+ "The configured AI model does not support image attachments. Contact the site administrator.":
205
+ "Le modèle d’IA configuré ne prend pas en charge les pièces jointes image. Contactez l’administrateur du site.",
204
206
  "The description for the image.": "Description de l'image.",
205
207
  "The excerpt for the post.":
206
208
  "Facultatif. Bref résumé pouvant apparaître dans les résultats de recherche et les aperçus.",
package/src/i18n/he.ts CHANGED
@@ -196,6 +196,8 @@ export const heDict: Record<string, string> = {
196
196
  Thai: "תאילנדי",
197
197
  "The alt text for the image.": "הטקסט האלטרנטיבי לתמונה.",
198
198
  "The caption for the image.": "הכיתוב לתמונה.",
199
+ "The configured AI model does not support image attachments. Contact the site administrator.":
200
+ "מודל הבינה המלאכותית שהוגדר אינו תומך בצירוף תמונות. פנו למנהל האתר.",
199
201
  "The description for the image.": "התיאור לתמונה.",
200
202
  "The excerpt for the post.":
201
203
  "אופציונלי. תקציר קצר שעשוי להופיע בתוצאות חיפוש ובתצוגות מקדימות.",
package/src/i18n/hi.ts CHANGED
@@ -199,6 +199,8 @@ export const hiDict: Record<string, string> = {
199
199
  Thai: "थाई",
200
200
  "The alt text for the image.": "छवि के लिए वैकल्पिक टेक्स्ट।",
201
201
  "The caption for the image.": "चित्र का कैप्शन।",
202
+ "The configured AI model does not support image attachments. Contact the site administrator.":
203
+ "कॉन्फ़िगर किया गया AI मॉडल छवि अटैचमेंट का समर्थन नहीं करता। साइट व्यवस्थापक से संपर्क करें।",
202
204
  "The description for the image.": "छवि का विवरण।",
203
205
  "The excerpt for the post.":
204
206
  "वैकल्पिक। छोटा सारांश जो खोज परिणामों और पूर्वावलोकन में दिख सकता है।",
package/src/i18n/hu.ts CHANGED
@@ -214,6 +214,8 @@ export const huDict: Record<string, string> = {
214
214
  Thai: "thai",
215
215
  "The alt text for the image.": "A képhez tartozó alt szöveg.",
216
216
  "The caption for the image.": "A kép felirata.",
217
+ "The configured AI model does not support image attachments. Contact the site administrator.":
218
+ "A beállított AI-modell nem támogatja a képek csatolását. Fordulj a webhely adminisztrátorához.",
217
219
  "The description for the image.": "A kép leírása.",
218
220
  "The excerpt for the post.":
219
221
  "Opcionális. Rövid összefoglaló, amely megjelenhet a keresési találatokban és az előnézetekben.",
package/src/i18n/id.ts CHANGED
@@ -200,6 +200,8 @@ export const idDict: Record<string, string> = {
200
200
  Thai: "Thai",
201
201
  "The alt text for the image.": "Teks alt untuk gambar.",
202
202
  "The caption for the image.": "Keterangan untuk gambar tersebut.",
203
+ "The configured AI model does not support image attachments. Contact the site administrator.":
204
+ "Model AI yang dikonfigurasi tidak mendukung lampiran gambar. Hubungi administrator situs.",
203
205
  "The description for the image.": "Deskripsi untuk gambar tersebut.",
204
206
  "The excerpt for the post.":
205
207
  "Opsional. Ringkasan singkat yang dapat muncul di hasil pencarian dan pratinjau.",
package/src/i18n/it.ts CHANGED
@@ -202,6 +202,8 @@ export const itDict: Record<string, string> = {
202
202
  Thai: "tailandese",
203
203
  "The alt text for the image.": "Il testo alternativo dell'immagine.",
204
204
  "The caption for the image.": "La didascalia dell'immagine.",
205
+ "The configured AI model does not support image attachments. Contact the site administrator.":
206
+ "Il modello di IA configurato non supporta gli allegati immagine. Contatta l'amministratore del sito.",
205
207
  "The description for the image.": "La descrizione dell'immagine.",
206
208
  "The excerpt for the post.":
207
209
  "Facoltativo. Breve riepilogo che può comparire nei risultati di ricerca e nelle anteprime.",
package/src/i18n/ja.ts CHANGED
@@ -201,6 +201,8 @@ export const jaDict: Record<string, string> = {
201
201
  Thai: "タイ語",
202
202
  "The alt text for the image.": "画像の代替テキスト。",
203
203
  "The caption for the image.": "画像のキャプション。",
204
+ "The configured AI model does not support image attachments. Contact the site administrator.":
205
+ "構成された AI モデルは画像添付に対応していません。サイト管理者にお問い合わせください。",
204
206
  "The description for the image.": "画像の説明。",
205
207
  "The excerpt for the post.":
206
208
  "任意。検索結果やプレビューに表示される可能性のある短い要約です。",
package/src/i18n/ko.ts CHANGED
@@ -199,6 +199,8 @@ export const koDict: Record<string, string> = {
199
199
  Thai: "태국",
200
200
  "The alt text for the image.": "이미지의 대체 텍스트입니다.",
201
201
  "The caption for the image.": "이미지에 대한 설명입니다.",
202
+ "The configured AI model does not support image attachments. Contact the site administrator.":
203
+ "구성된 AI 모델은 이미지 첨부를 지원하지 않습니다. 사이트 관리자에게 문의하세요.",
202
204
  "The description for the image.": "이미지에 대한 설명입니다.",
203
205
  "The excerpt for the post.":
204
206
  "선택 사항. 검색 결과와 미리보기에서 표시될 수 있는 짧은 요약입니다.",
package/src/i18n/nb.ts CHANGED
@@ -198,6 +198,8 @@ export const nbDict: Record<string, string> = {
198
198
  Thai: "Thai",
199
199
  "The alt text for the image.": "Alt-teksten for bildet.",
200
200
  "The caption for the image.": "Bildeteksten til bildet.",
201
+ "The configured AI model does not support image attachments. Contact the site administrator.":
202
+ "Den konfigurerte KI-modellen støtter ikke bildevedlegg. Kontakt nettstedsadministratoren.",
201
203
  "The description for the image.": "Beskrivelsen for bildet.",
202
204
  "The excerpt for the post.":
203
205
  "Valgfritt. Kort sammendrag som kan vises i søkeresultater og forhåndsvisninger.",
package/src/i18n/nl.ts CHANGED
@@ -199,6 +199,8 @@ export const nlDict: Record<string, string> = {
199
199
  Thai: "Thais",
200
200
  "The alt text for the image.": "De alternatieve tekst voor de afbeelding.",
201
201
  "The caption for the image.": "Het onderschrift bij de afbeelding.",
202
+ "The configured AI model does not support image attachments. Contact the site administrator.":
203
+ "Het geconfigureerde AI-model ondersteunt geen afbeeldingsbijlagen. Neem contact op met de sitebeheerder.",
202
204
  "The description for the image.": "De beschrijving bij de afbeelding.",
203
205
  "The excerpt for the post.":
204
206
  "Optioneel. Korte samenvatting die kan verschijnen in zoekresultaten en previews.",
package/src/i18n/pl.ts CHANGED
@@ -202,6 +202,8 @@ export const plDict: Record<string, string> = {
202
202
  Thai: "tajski",
203
203
  "The alt text for the image.": "Tekst alternatywny dla obrazka.",
204
204
  "The caption for the image.": "Podpis pod obrazkiem.",
205
+ "The configured AI model does not support image attachments. Contact the site administrator.":
206
+ "Skonfigurowany model AI nie obsługuje załączników graficznych. Skontaktuj się z administratorem witryny.",
205
207
  "The description for the image.": "Opis obrazu.",
206
208
  "The excerpt for the post.":
207
209
  "Opcjonalne. Krótkie podsumowanie, które może pojawić się w wynikach wyszukiwania i podglądach.",
package/src/i18n/pt.ts CHANGED
@@ -199,6 +199,8 @@ export const ptDict: Record<string, string> = {
199
199
  Thai: "Tailandês",
200
200
  "The alt text for the image.": "O texto alternativo da imagem.",
201
201
  "The caption for the image.": "Legenda da imagem.",
202
+ "The configured AI model does not support image attachments. Contact the site administrator.":
203
+ "O modelo de IA configurado não suporta anexos de imagem. Contacte o administrador do site.",
202
204
  "The description for the image.": "Descrição da imagem.",
203
205
  "The excerpt for the post.":
204
206
  "Opcional. Um breve resumo que pode aparecer nos resultados de pesquisa e nas pré-visualizações.",
package/src/i18n/ru.ts CHANGED
@@ -199,6 +199,8 @@ export const ruDict: Record<string, string> = {
199
199
  Thai: "Тайский",
200
200
  "The alt text for the image.": "Альтернативный текст для изображения.",
201
201
  "The caption for the image.": "Подпись к изображению.",
202
+ "The configured AI model does not support image attachments. Contact the site administrator.":
203
+ "Настроенная модель ИИ не поддерживает вложения изображений. Обратитесь к администратору сайта.",
202
204
  "The description for the image.": "Описание изображения.",
203
205
  "The excerpt for the post.":
204
206
  "Необязательно. Короткое описание, которое может отображаться в результатах поиска и предпросмотрах.",
package/src/i18n/sv.ts CHANGED
@@ -198,6 +198,8 @@ export const svDict: Record<string, string> = {
198
198
  Thai: "Thailändsk",
199
199
  "The alt text for the image.": "Alt-texten för bilden.",
200
200
  "The caption for the image.": "Bildtexten till bilden.",
201
+ "The configured AI model does not support image attachments. Contact the site administrator.":
202
+ "Den konfigurerade AI-modellen stöder inte bildbilagor. Kontakta webbplatsadministratören.",
201
203
  "The description for the image.": "Beskrivningen för bilden.",
202
204
  "The excerpt for the post.":
203
205
  "Valfritt. Kort sammanfattning som kan visas i sökresultat och förhandsvisningar.",
package/src/i18n/th.ts CHANGED
@@ -198,6 +198,8 @@ export const thDict: Record<string, string> = {
198
198
  Thai: "แบบไทย",
199
199
  "The alt text for the image.": "ข้อความอธิบายภาพ (alt text) สำหรับรูปภาพ",
200
200
  "The caption for the image.": "คำบรรยายใต้ภาพ",
201
+ "The configured AI model does not support image attachments. Contact the site administrator.":
202
+ "โมเดล AI ที่กำหนดค่าไว้ไม่รองรับไฟล์แนบรูปภาพ โปรดติดต่อผู้ดูแลเว็บไซต์",
201
203
  "The description for the image.": "คำอธิบายภาพ",
202
204
  "The excerpt for the post.":
203
205
  "ไม่บังคับ ข้อความสรุปสั้นๆ ที่อาจแสดงในผลการค้นหาและตัวอย่างแสดงผล",
package/src/i18n/tr.ts CHANGED
@@ -201,6 +201,8 @@ export const trDict: Record<string, string> = {
201
201
  Thai: "Tayland",
202
202
  "The alt text for the image.": "Görselin alternatif metni.",
203
203
  "The caption for the image.": "Görselin altındaki açıklama.",
204
+ "The configured AI model does not support image attachments. Contact the site administrator.":
205
+ "Yapılandırılmış AI modeli görsel eklerini desteklemiyor. Site yöneticisiyle iletişime geçin.",
204
206
  "The description for the image.": "Görselin açıklaması.",
205
207
  "The excerpt for the post.":
206
208
  "İsteğe bağlı. Arama sonuçlarında ve önizlemelerde görünebilecek kısa özet.",
package/src/i18n/ua.ts CHANGED
@@ -200,6 +200,8 @@ export const uaDict: Record<string, string> = {
200
200
  Thai: "Тайська",
201
201
  "The alt text for the image.": "Альтернативний текст для зображення.",
202
202
  "The caption for the image.": "Підпис до зображення.",
203
+ "The configured AI model does not support image attachments. Contact the site administrator.":
204
+ "Налаштована модель ШІ не підтримує вкладення зображень. Зверніться до адміністратора сайту.",
203
205
  "The description for the image.": "Опис зображення.",
204
206
  "The excerpt for the post.":
205
207
  "Необов’язково. Короткий опис, який може відображатися в результатах пошуку та попередньому перегляді.",
package/src/i18n/zh.ts CHANGED
@@ -194,6 +194,8 @@ export const zhDict: Record<string, string> = {
194
194
  Thai: "泰国",
195
195
  "The alt text for the image.": "图片的替代文字。",
196
196
  "The caption for the image.": "图片说明文字。",
197
+ "The configured AI model does not support image attachments. Contact the site administrator.":
198
+ "配置的 AI 模型不支持图片附件。请联系网站管理员。",
197
199
  "The description for the image.": "图片描述。",
198
200
  "The excerpt for the post.": "可选。可能显示在搜索结果和预览中的简短摘要。",
199
201
  "The format for the generated output.": "生成输出的格式。",
@@ -9,6 +9,8 @@ const CHATBOT_DISCLOSURE =
9
9
  "Answers from {name} are generated by AI and may contain mistakes. Check important information.";
10
10
  const DOC_SEARCH_DISCLOSURE =
11
11
  "This summary was generated by AI and may contain mistakes. Check important information.";
12
+ const MODEL_CAPABILITY_ERROR =
13
+ "The configured AI model does not support image attachments. Contact the site administrator.";
12
14
 
13
15
  const importTypeScript = async (fileUrl: URL) => {
14
16
  const source = await fs.readFile(fileUrl, "utf8");
@@ -60,6 +62,10 @@ test("all supported languages contain alphabetized AI disclosures", async () =>
60
62
  dictionary[DOC_SEARCH_DISCLOSURE]?.trim(),
61
63
  `${file} must translate the DocSearch disclosure`,
62
64
  );
65
+ assert.ok(
66
+ dictionary[MODEL_CAPABILITY_ERROR]?.trim(),
67
+ `${file} must translate the model capability error`,
68
+ );
63
69
 
64
70
  const keys = Object.keys(dictionary);
65
71
  assert.equal(
@@ -72,6 +78,11 @@ test("all supported languages contain alphabetized AI disclosures", async () =>
72
78
  keys.indexOf("Title") - 1,
73
79
  `${file} must keep the DocSearch disclosure alphabetized`,
74
80
  );
81
+ assert.equal(
82
+ keys.indexOf(MODEL_CAPABILITY_ERROR),
83
+ keys.indexOf("The caption for the image.") + 1,
84
+ `${file} must keep the model capability error alphabetized`,
85
+ );
75
86
  }
76
87
  });
77
88
 
@@ -95,3 +106,21 @@ test("renders the chatbot disclosure beside status and outside the composer box"
95
106
  "disclosure must be outside and above the composer box",
96
107
  );
97
108
  });
109
+
110
+ test("keeps chatbot image attachments explicitly opt-in", async () => {
111
+ const component = await fs.readFile(
112
+ new URL("../src/ai-chatbot/AiChatbot.tsx", import.meta.url),
113
+ "utf8",
114
+ );
115
+
116
+ assert.match(component, /const DEFAULT_MAX_IMAGES = 0;/);
117
+ assert.match(
118
+ component,
119
+ /const imageAttachmentsEnabled = resolvedMaxImages > 0;/,
120
+ );
121
+ assert.match(
122
+ component,
123
+ /const selectedImages = imageAttachmentsEnabled[\s\S]*?composerImagesRef\.current[\s\S]*?: \[\];/,
124
+ );
125
+ assert.match(component, /\{imageAttachmentsEnabled && \(/);
126
+ });
@@ -104,6 +104,23 @@ test("distinguishes authorization, throttling, network, and backend failures", (
104
104
  );
105
105
  });
106
106
 
107
+ test("explains a configured model capability mismatch", () => {
108
+ const details = normalizeAiRunError(
109
+ backendError(400, {
110
+ code: "MODEL_CAPABILITY_ERROR",
111
+ message: "The configured AI model does not support image attachments.",
112
+ requestId: "req-model-capability",
113
+ }),
114
+ );
115
+
116
+ assert.equal(details.kind, "validation");
117
+ assert.equal(details.code, "MODEL_CAPABILITY_ERROR");
118
+ assert.equal(
119
+ getAiRunErrorMessage(details),
120
+ "The configured AI model does not support image attachments. Contact the site administrator.",
121
+ );
122
+ });
123
+
107
124
  test("treats intentional cancellation as non-error feedback", () => {
108
125
  const feedback = createAiRunErrorFeedback(
109
126
  new DOMException("Aborted", "AbortError"),