Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable react-hooks/refs */
import { memo, useRef, useEffect } from "react";
import { useTranslation } from "react-i18next";
import { Warning } from "@phosphor-icons/react";
import renderMarkdown from "@/utils/chat/markdown";
import DOMPurify from "@/utils/chat/purify";
Expand All @@ -12,13 +13,27 @@ import {
} from "../ThoughtContainer";

const PromptReply = ({ uuid, reply, pending, error, sources = [] }) => {
const { t } = useTranslation();
if (!reply && sources.length === 0 && !pending && !error) return null;

if (pending) {
return (
<div className="flex justify-start w-full">
<div className="py-4 pl-0 pr-4 flex flex-col md:max-w-[80%]">
<div className="mt-3 ml-1 dot-falling light:invert"></div>
{/*
The animation below is the only signal that a reply is coming, and it
is purely visual. The status region gives a screen reader user the
same information. It carries the text rather than wrapping the
animation so that it announces once, on appearance, instead of on
every repaint.
*/}
<span className="sr-only" role="status">
{t("chat_window.generating_response")}
</span>
<div
className="mt-3 ml-1 dot-falling light:invert"
aria-hidden="true"
></div>
</div>
</div>
);
Expand All @@ -28,10 +43,22 @@ const PromptReply = ({ uuid, reply, pending, error, sources = [] }) => {
return (
<div className="flex justify-start w-full">
<div className="py-4 pl-0 pr-4 flex flex-col md:max-w-[80%]">
<span className="inline-block p-2 rounded-lg bg-red-50 text-red-500">
<Warning className="h-4 w-4 mb-1 inline-block" /> Could not respond
to message.
<span className="text-xs">Reason: {error || "unknown"}</span>
{/*
role="alert" rather than "status": a failed reply is the one case
where the user needs interrupting, because nothing else on the page
changes to tell them the turn ended.
*/}
<span
className="inline-block p-2 rounded-lg bg-red-50 text-red-500"
role="alert"
>
<Warning className="h-4 w-4 mb-1 inline-block" />{" "}
{t("chat_window.response_failed")}
<span className="text-xs">
{t("chat_window.response_failed_reason", {
reason: error || "unknown",
})}
</span>
</span>
</div>
</div>
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/ar/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,9 @@ const TRANSLATIONS = {
export: "تصدير المحادثة كـ...",
exporting: "التصدير...",
preset_img_description: "إنشاء صورة بناءً على نص معين.",
generating_response: "إنشاء رد",
response_failed: "لم أتمكن من الرد على الرسالة.",
response_failed_reason: "السبب: {{reason}}",
},
profile_settings: {
edit_account: "تحرير الحساب",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/ca/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1511,6 +1511,9 @@ const TRANSLATIONS = {
export: "Exporta la conversa com a...",
exporting: "Exportant…",
preset_img_description: "Generar una imatge a partir d'un text",
generating_response: "Generar resposta",
response_failed: "No he pogut respondre al missatge.",
response_failed_reason: "Motiu: {{reason}}",
},
profile_settings: {
edit_account: "Edita el compte",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/cs/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1418,6 +1418,9 @@ const TRANSLATIONS = {
export: "Exportujte konverzaci jako…",
exporting: "Exportování...",
preset_img_description: "Vytvořit obrázek na základě textového pokynu",
generating_response: "Generování odpovědi",
response_failed: "Nebyl možné odpovědět na zprávu.",
response_failed_reason: "Důvod: {{reason}}",
},
profile_settings: {
edit_account: "Upravit účet",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/da/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1293,6 +1293,9 @@ const TRANSLATIONS = {
export: "Eksportér chat som...",
exporting: "Eksportér...",
preset_img_description: "Generer et billede ud fra en tekstbeskrivelse",
generating_response: "Generere svar",
response_failed: "Kunne ikke svare på beskeden.",
response_failed_reason: "Årsag: {{reason}}",
},
profile_settings: {
edit_account: "Rediger konto",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/de/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1417,6 +1417,9 @@ const TRANSLATIONS = {
exporting: "Exportieren...",
preset_img_description:
"Erstelle ein Bild basierend auf einer Textanfrage.",
generating_response: "Antwort generieren",
response_failed: "Ich konnte die Nachricht nicht beantworten.",
response_failed_reason: "Grund: {{reason}}",
},
profile_settings: {
edit_account: "Account bearbeiten",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/en/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1524,6 +1524,9 @@ const TRANSLATIONS = {
},
chat_window: {
attachments_processing: "Attachments are processing. Please wait...",
generating_response: "Generating response",
response_failed: "Could not respond to message.",
response_failed_reason: "Reason: {{reason}}",
send_message: "Send a message",
attach_file: "Attach a file to this chat",
text_size: "Change text size.",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/es/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1432,6 +1432,9 @@ const TRANSLATIONS = {
exporting: "Exportando...",
preset_img_description:
"Generar una imagen a partir de una descripción textual.",
generating_response: "Generar respuesta",
response_failed: "No fue posible responder al mensaje.",
response_failed_reason: "Razón: {{reason}}",
},
profile_settings: {
edit_account: "Editar cuenta",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/et/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1358,6 +1358,9 @@ const TRANSLATIONS = {
export: "Экспорти руй чат kui...",
exporting: "Экспорт",
preset_img_description: "Loo pilt tekstist antud juhiste põhjal",
generating_response: "Vastus genereerimine",
response_failed: "Ei olnud võimalik vastata teatele.",
response_failed_reason: "põhjus: {{reason}}",
},
profile_settings: {
edit_account: "Muuda kontot",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/fa/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1285,6 +1285,9 @@ const TRANSLATIONS = {
export: "صدور چت به صورت...",
exporting: "صدور به خارج",
preset_img_description: "ایجاد یک تصویر بر اساس یک دستور متنی",
generating_response: "تولید پاسخ",
response_failed: "امکان پاسخ دادن به پیام وجود نداشت.",
response_failed_reason: "دلیل: {{reason}}",
},
profile_settings: {
edit_account: "ویرایش حساب",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/fr/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,9 @@ const TRANSLATIONS = {
exporting: "Exportation...",
preset_img_description:
"Générer une image à partir d'une requête textuelle.",
generating_response: "Générer une réponse",
response_failed: "Impossible de répondre au message.",
response_failed_reason: "Raison : {{reason}}",
},
profile_settings: {
edit_account: "Modifier le compte",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/he/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,9 @@ const TRANSLATIONS = {
export: "ייצוא צ'אט כ...",
exporting: "ייצוא...",
preset_img_description: "יצירת תמונה על סמך הנחיה טקסטואלית",
generating_response: "יצירת תגובה",
response_failed: "לא ניתן להגיב למסר.",
response_failed_reason: "סיבה: {{reason}}",
},
profile_settings: {
edit_account: "ערוך חשבון",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/hr/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1665,6 +1665,9 @@ const TRANSLATIONS = {
},
},
preset_img_description: "Generiraj sliku na temelju tekstualnog uputa.",
generating_response: "Generiranje odgovora",
response_failed: "Nije moguće odgovoriti na poruku.",
response_failed_reason: "Razlog: {{reason}}",
},
profile_settings: {
edit_account: "Uredi račun",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/id/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1661,6 +1661,9 @@ const TRANSLATIONS = {
},
},
preset_img_description: "Hasilkan gambar berdasarkan teks yang diberikan.",
generating_response: "Menghasilkan respons",
response_failed: "Tidak dapat membalas pesan tersebut.",
response_failed_reason: "Alasan: {{reason}}",
},
profile_settings: {
edit_account: "Edit Akun",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/it/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1324,6 +1324,9 @@ const TRANSLATIONS = {
export: "Esporta la conversazione come...",
exporting: "Esportazione...",
preset_img_description: "Genera un'immagine a partire da un testo",
generating_response: "Generare una risposta",
response_failed: "Non è stato possibile rispondere al messaggio.",
response_failed_reason: "Motivo: {{reason}}",
},
profile_settings: {
edit_account: "Modifica account",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/ja/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,9 @@ const TRANSLATIONS = {
export: "チャットを以下のような形式でエクスポートする:",
exporting: "輸出…",
preset_img_description: "テキストプロンプトから画像を生成する。",
generating_response: "応答を生成する",
response_failed: "メッセージへの返信ができませんでした。",
response_failed_reason: "理由:{{reason}}",
},
profile_settings: {
edit_account: "アカウントを編集",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/ko/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1359,6 +1359,9 @@ const TRANSLATIONS = {
export: "채팅 내용을 다음 형식으로 내보내기:",
exporting: "수출 중…",
preset_img_description: "텍스트 프롬프트에서 이미지를 생성합니다.",
generating_response: "응답 생성",
response_failed: "메시지에 응답할 수 없었습니다.",
response_failed_reason: "이유: {{reason}}",
},
profile_settings: {
edit_account: "계정 정보 수정",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/lo/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1579,6 +1579,9 @@ const TRANSLATIONS = {
},
},
preset_img_description: "ຈາກຂໍ້ຄວາມ ໃຫ້ສ້າງຮູບພາບ",
generating_response: "ຜົນການຕອບ",
response_failed: "ສາมาถ ප්‍රතිສະໜອງ ຂໍ້ຄວາມ ໄດ້",
response_failed_reason: "ສາเหตุ: {{reason}}",
},
profile_settings: {
edit_account: "ແກ້ໄຂບັນຊີ",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/lt/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,9 @@ const TRANSLATIONS = {
export: "Eksporteri pokalbį kaip…",
exporting: "Eksporteris...",
preset_img_description: "Sukurkite vaizdą iš teksto instrukcijos",
generating_response: "Sukurti atsakymą",
response_failed: "Nepavyko atsakyti į pranešimą.",
response_failed_reason: "Priežastis: {{reason}}",
},
profile_settings: {
edit_account: "Redaguoti paskyrą",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/lv/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1402,6 +1402,9 @@ const TRANSLATIONS = {
export: "Eksportēt čatu kā...",
exporting: "Eksporteris…",
preset_img_description: "Izveidot attēlu no teksta norādījuma",
generating_response: "Atbildes izveide",
response_failed: "Neizdevās atbildēt uz ziņojumu.",
response_failed_reason: "Iemesls: {{reason}}",
},
profile_settings: {
edit_account: "Rediģēt kontu",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/nl/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1305,6 +1305,9 @@ const TRANSLATIONS = {
exporting: "Exporteren...",
preset_img_description:
"Genereer een afbeelding op basis van een tekstuele instructie.",
generating_response: "Antwoord genereren",
response_failed: "Kon de bericht niet beantwoorden.",
response_failed_reason: "Reden: {{reason}}",
},
profile_settings: {
edit_account: "Account bewerken",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/pl/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1409,6 +1409,9 @@ const TRANSLATIONS = {
export: "Eksportuj czat jako…",
exporting: "Eksportowanie...",
preset_img_description: "Wygeneruj obraz na podstawie tekstu",
generating_response: "Generowanie odpowiedzi",
response_failed: "Nie udało się odpowiedzieć na wiadomość.",
response_failed_reason: "Powód: {{reason}}",
},
profile_settings: {
edit_account: "Edytuj konto",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/pt_BR/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1392,6 +1392,9 @@ const TRANSLATIONS = {
export: "Exporte a conversa como...",
exporting: "Exportando...",
preset_img_description: "Gerar uma imagem a partir de um texto",
generating_response: "Gerando resposta",
response_failed: "Não foi possível responder à mensagem.",
response_failed_reason: "Motivo: {{reason}}",
},
profile_settings: {
edit_account: "Editar conta",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/ro/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,9 @@ const TRANSLATIONS = {
export: "Exportați conversația sub forma de...",
exporting: "Exportare...",
preset_img_description: "Generați o imagine pe baza unui text.",
generating_response: "Generarea răspunsului",
response_failed: "Nu am putut răspunde la mesaj.",
response_failed_reason: "Motiv: {{reason}}",
},
profile_settings: {
edit_account: "Editează contul",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/ru/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1313,6 +1313,9 @@ const TRANSLATIONS = {
export: "Экспортировать чат в формате…",
exporting: "Экспорт...",
preset_img_description: "Создать изображение на основе текстового запроса",
generating_response: "Формирование ответа",
response_failed: "Не удалось ответить на сообщение.",
response_failed_reason: "Причина: {{reason}}",
},
profile_settings: {
edit_account: "Редактировать учётную запись",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/tr/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,9 @@ const TRANSLATIONS = {
export: "Çat sohbetini şu şekilde dışa aktar:",
exporting: "Dışarıya satışı yapma...",
preset_img_description: "Bir metin isteminden bir görüntü oluşturun",
generating_response: "Yanıt üretme",
response_failed: "Mesaja cevap veremedim.",
response_failed_reason: "Nedeni: {{reason}}",
},
profile_settings: {
edit_account: "Hesabı Düzenle",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/vn/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,9 @@ const TRANSLATIONS = {
export: "Xuất trò chuyện dưới dạng...",
exporting: "Xuất khẩu...",
preset_img_description: "Tạo một hình ảnh từ một đoạn mô tả bằng văn bản.",
generating_response: "Tạo ra câu trả lời",
response_failed: "Không thể phản hồi tin nhắn.",
response_failed_reason: "Lý do: {{reason}}",
},
profile_settings: {
edit_account: "Chỉnh sửa Tài khoản",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/zh/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,9 @@ const TRANSLATIONS = {
export: "导出聊天记录为…",
exporting: "出口…",
preset_img_description: "根据文本提示生成图像。",
generating_response: "生成回复",
response_failed: "无法回复消息。",
response_failed_reason: "原因:{{reason}}",
},
profile_settings: {
edit_account: "编辑帐户",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locales/zh_TW/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1209,6 +1209,9 @@ const TRANSLATIONS = {
export: "匯出對話內容為…",
exporting: "出口...",
preset_img_description: "根據文字提示,生成圖像。",
generating_response: "產生回應",
response_failed: "無法回覆訊息。",
response_failed_reason: "原因:{{reason}}",
},
profile_settings: {
edit_account: "編輯帳戶",
Expand Down
Loading