diff --git a/bun.lockb b/bun.lockb index f5c5689..b982106 100644 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 236c93d..f7d9ebd 100644 --- a/package.json +++ b/package.json @@ -58,6 +58,7 @@ "remark-math": "5.1.1", "tesseract.js": "^5.1.1", "turndown": "^7.1.3", + "unist-util-visit": "^5.0.0", "yt-transcript": "^0.0.2", "zustand": "^4.5.0" }, diff --git a/src/assets/locale/ar/common.json b/src/assets/locale/ar/common.json index 6c2d77a..a4be827 100644 --- a/src/assets/locale/ar/common.json +++ b/src/assets/locale/ar/common.json @@ -125,5 +125,9 @@ "pin": "تثبيت", "unpin": "إلغاء التثبيت", "generationInfo": "معلومات التوليد", - "sidebarChat": "دردشة الشريط الجانبي" + "sidebarChat": "دردشة الشريط الجانبي", + "reasoning": { + "thinking": "جاري التفكير....", + "thought": "فكر لمدة {{time}}" + } } diff --git a/src/assets/locale/da/common.json b/src/assets/locale/da/common.json index 9b2b30b..f03f256 100644 --- a/src/assets/locale/da/common.json +++ b/src/assets/locale/da/common.json @@ -118,5 +118,9 @@ "pin": "Fastgør", "unpin": "Frigør", "generationInfo": "Genererings Info", - "sidebarChat": "Sidepanel Chat" + "sidebarChat": "Sidepanel Chat", + "reasoning": { + "thinking": "Tænker....", + "thought": "Tænkte i {{time}}" + } } \ No newline at end of file diff --git a/src/assets/locale/de/common.json b/src/assets/locale/de/common.json index d6bb325..ec6c25e 100644 --- a/src/assets/locale/de/common.json +++ b/src/assets/locale/de/common.json @@ -118,5 +118,9 @@ "pin": "Anheften", "unpin": "Losheften", "generationInfo": "Generierungsinformationen", - "sidebarChat": "Seitenleisten-Chat" + "sidebarChat": "Seitenleisten-Chat", + "reasoning": { + "thinking": "Denke nach....", + "thought": "Gedanke für {{time}}" + } } \ No newline at end of file diff --git a/src/assets/locale/en/common.json b/src/assets/locale/en/common.json index 2268c8d..03fb2e6 100644 --- a/src/assets/locale/en/common.json +++ b/src/assets/locale/en/common.json @@ -152,5 +152,9 @@ "pin": "Pin", "unpin": "Unpin", "generationInfo": "Generation Info", - "sidebarChat": "Sidebar Chat" + "sidebarChat": "Sidebar Chat", + "reasoning": { + "thinking": "Thinking....", + "thought": "Thought for {{time}}" + } } \ No newline at end of file diff --git a/src/assets/locale/es/common.json b/src/assets/locale/es/common.json index 4a3967c..aa5b01e 100644 --- a/src/assets/locale/es/common.json +++ b/src/assets/locale/es/common.json @@ -117,5 +117,9 @@ "pin": "Fijar", "unpin": "Desfijar", "generationInfo": "Información de Generación", - "sidebarChat": "Chat lateral" + "sidebarChat": "Chat lateral", + "reasoning": { + "thinking": "Pensando....", + "thought": "Pensamiento por {{time}}" + } } \ No newline at end of file diff --git a/src/assets/locale/fa/common.json b/src/assets/locale/fa/common.json index 8532074..dfe57d9 100644 --- a/src/assets/locale/fa/common.json +++ b/src/assets/locale/fa/common.json @@ -111,5 +111,9 @@ "pin": "پین کردن", "unpin": "حذف پین", "generationInfo": "اطلاعات تولید", - "sidebarChat": "چت کناری" + "sidebarChat": "چت کناری", + "reasoning": { + "thinking": "در حال فکر کردن....", + "thought": "فکر کردن برای {{time}}" + } } \ No newline at end of file diff --git a/src/assets/locale/fr/common.json b/src/assets/locale/fr/common.json index 432c2c0..1fa66aa 100644 --- a/src/assets/locale/fr/common.json +++ b/src/assets/locale/fr/common.json @@ -117,5 +117,9 @@ "pin": "Épingler", "unpin": "Désépingler", "generationInfo": "Informations de génération", - "sidebarChat": "Chat latéral" + "sidebarChat": "Chat latéral", + "reasoning": { + "thinking": "Réflexion....", + "thought": "Réflexion pendant {{time}}" + } } \ No newline at end of file diff --git a/src/assets/locale/it/common.json b/src/assets/locale/it/common.json index edcc2b8..027101d 100644 --- a/src/assets/locale/it/common.json +++ b/src/assets/locale/it/common.json @@ -117,5 +117,9 @@ "pin": "Fissa", "unpin": "Rimuovi", "generationInfo": "Informazioni sulla Generazione", - "sidebarChat": "Chat Laterale" + "sidebarChat": "Chat Laterale", + "reasoning": { + "thinking": "Pensando....", + "thought": "Pensato per {{time}}" + } } \ No newline at end of file diff --git a/src/assets/locale/ja-JP/common.json b/src/assets/locale/ja-JP/common.json index dd2700b..d742427 100644 --- a/src/assets/locale/ja-JP/common.json +++ b/src/assets/locale/ja-JP/common.json @@ -117,5 +117,9 @@ "pin": "固定", "unpin": "固定解除", "generationInfo": "生成情報", - "sidebarChat": "サイドバーチャット" + "sidebarChat": "サイドバーチャット", + "reasoning": { + "thinking": "考え中....", + "thought": "{{time}}の思考" + } } \ No newline at end of file diff --git a/src/assets/locale/ko/common.json b/src/assets/locale/ko/common.json index 0e83e43..ef6511b 100644 --- a/src/assets/locale/ko/common.json +++ b/src/assets/locale/ko/common.json @@ -117,5 +117,9 @@ "pin": "고정", "unpin": "고정 해제", "generationInfo": "생성 정보", - "sidebarChat": "사이드바 채팅" + "sidebarChat": "사이드바 채팅", + "reasoning": { + "thinking": "생각 중....", + "thought": "{{time}} 동안 생각함" + } } \ No newline at end of file diff --git a/src/assets/locale/ml/common.json b/src/assets/locale/ml/common.json index ae5489a..ddaff67 100644 --- a/src/assets/locale/ml/common.json +++ b/src/assets/locale/ml/common.json @@ -116,6 +116,9 @@ "pin": "പിൻ ചെയ്യുക", "unpin": "അൺപിൻ ചെയ്യുക", "generationInfo": "ജനറേഷൻ വിവരങ്ങൾ", - "sidebarChat": "സൈഡ്ബാർ ചാറ്റ്" - + "sidebarChat": "സൈഡ്ബാർ ചാറ്റ്", + "reasoning": { + "thinking": "ചിന്തിക്കുന്നു....", + "thought": "{{time}} നേരത്തെ ചിന്ത" + } } \ No newline at end of file diff --git a/src/assets/locale/no/common.json b/src/assets/locale/no/common.json index 24b51b5..a762bed 100644 --- a/src/assets/locale/no/common.json +++ b/src/assets/locale/no/common.json @@ -118,5 +118,9 @@ "pin": "Fest", "unpin": "Løsne", "generationInfo": "Generasjonsinformasjon", - "sidebarChat": "Sidepanel-chat" + "sidebarChat": "Sidepanel-chat", + "reasoning": { + "thinking": "Tenker....", + "thought": "Tenkte i {{time}}" + } } \ No newline at end of file diff --git a/src/assets/locale/pt-BR/common.json b/src/assets/locale/pt-BR/common.json index 4e1a15b..6e3b387 100644 --- a/src/assets/locale/pt-BR/common.json +++ b/src/assets/locale/pt-BR/common.json @@ -117,5 +117,9 @@ "pin": "Fixar", "unpin": "Desafixar", "generationInfo": "Informações de Geração", - "sidebarChat": "Chat Lateral" + "sidebarChat": "Chat Lateral", + "reasoning": { + "thinking": "Pensando....", + "thought": "Pensou por {{time}}" + } } \ No newline at end of file diff --git a/src/assets/locale/ru/common.json b/src/assets/locale/ru/common.json index cbdc13d..e661445 100644 --- a/src/assets/locale/ru/common.json +++ b/src/assets/locale/ru/common.json @@ -117,5 +117,9 @@ "pin": "Закрепить", "unpin": "Открепить", "generationInfo": "Информация о генерации", - "sidebarChat": "Боковой чат" + "sidebarChat": "Боковой чат", + "reasoning": { + "thinking": "Размышляю...", + "thought": "Размышлял {{time}}" + } } \ No newline at end of file diff --git a/src/assets/locale/sv/common.json b/src/assets/locale/sv/common.json index 6918290..18cf17f 100644 --- a/src/assets/locale/sv/common.json +++ b/src/assets/locale/sv/common.json @@ -122,5 +122,9 @@ "pin": "Fäst", "unpin": "Ta bort fäst", "generationInfo": "Generationsinformation", - "sidebarChat": "Sidofältschatt" + "sidebarChat": "Sidofältschatt", + "reasoning": { + "thinking": "Tänker....", + "thought": "Tänkte i {{time}}" + } } \ No newline at end of file diff --git a/src/assets/locale/uk/common.json b/src/assets/locale/uk/common.json index b4773d4..16b4c48 100644 --- a/src/assets/locale/uk/common.json +++ b/src/assets/locale/uk/common.json @@ -122,5 +122,9 @@ "pin": "Прикріпити", "unpin": "Відкріпити", "generationInfo": "Інформація про генерацію", - "sidebarChat": "Бічний чат" + "sidebarChat": "Бічний чат", + "reasoning": { + "thinking": "Думаю....", + "thought": "Думав протягом {{time}}" + } } \ No newline at end of file diff --git a/src/assets/locale/zh/common.json b/src/assets/locale/zh/common.json index 4d01d24..6117f1a 100644 --- a/src/assets/locale/zh/common.json +++ b/src/assets/locale/zh/common.json @@ -117,5 +117,9 @@ "pin": "置顶", "unpin": "取消置顶", "generationInfo": "生成信息", - "sidebarChat": "侧边栏聊天" + "sidebarChat": "侧边栏聊天", + "reasoning": { + "thinking": "思考中....", + "thought": "思考了 {{time}}" + } } \ No newline at end of file diff --git a/src/components/Common/Playground/Message.tsx b/src/components/Common/Playground/Message.tsx index 79a7d23..a9991a8 100644 --- a/src/components/Common/Playground/Message.tsx +++ b/src/components/Common/Playground/Message.tsx @@ -18,7 +18,8 @@ import { useTTS } from "@/hooks/useTTS" import { tagColors } from "@/utils/color" import { removeModelSuffix } from "@/db/models" import { GenerationInfo } from "./GenerationInfo" - +import { parseReasoning } from "@/libs/reasoning" +import { humanizeMilliseconds } from "@/utils/humanize-miliseconds" type Props = { message: string message_type?: string @@ -40,6 +41,8 @@ type Props = { onSourceClick?: (source: any) => void isTTSEnabled?: boolean generationInfo?: any + isStreaming: boolean + reasoningTimeTaken?: number } export const PlaygroundMessage = (props: Props) => { @@ -48,7 +51,6 @@ export const PlaygroundMessage = (props: Props) => { const { t } = useTranslation("common") const { cancel, isSpeaking, speak } = useTTS() - return (
@@ -94,7 +96,40 @@ export const PlaygroundMessage = (props: Props) => {
{!editMode ? ( props.isBot ? ( - + <> + {parseReasoning(props.message).map((e, i) => { + if (e.type === "reasoning") { + return ( + + + {t("reasoning.thinking")} + +
+ ) : ( + t("reasoning.thought", { + time: humanizeMilliseconds( + props.reasoningTimeTaken + ) + }) + ), + children: + } + ]} + /> + ) + } + + return + })} + ) : (

{ } title={t("generationInfo")}> @@ -231,7 +266,7 @@ export const PlaygroundMessage = (props: Props) => { props.currentMessageIndex === props.totalMessages - 1 && (