Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

💄 style: support non-stream mode (#8751)

Arvin Xuce623bb280c7
diff --git a/locales/ar/setting.json b/locales/ar/setting.json
index 8cc1b34c0ac..fd4d628685d 100644
--- a/locales/ar/setting.json
+++ b/locales/ar/setting.json
@@ -237,6 +237,10 @@
"title": "تحديد عدد الرسائل التاريخية",
"unlimited": "غير محدود"
},
+ "enableStreaming": {
+ "desc": "تمكين الإخراج المتدفق لعرض الاستجابات في الوقت الفعلي. عند التعطيل، يتم عرض الاستجابة الكاملة فقط.",
+ "title": "تمكين الإخراج المتدفق"
+ },
"historyCount": {
"desc": "عدد الرسائل التي يتم إرفاقها في كل طلب (تشمل الأسئلة والأجوبة الجديدة. يُحسب كل سؤال وجواب كرسالة واحدة)",
"title": "عدد الرسائل المرفقة"
diff --git a/locales/bg-BG/setting.json b/locales/bg-BG/setting.json
index 514813b21ce..0871da30c92 100644
--- a/locales/bg-BG/setting.json
+++ b/locales/bg-BG/setting.json
@@ -237,6 +237,10 @@
"title": "Ограничаване на броя на съобщенията в историята",
"unlimited": "Неограничен брой съобщения в историята"
},
+ "enableStreaming": {
+ "desc": "Активирайте поточно предаване, за да показвате отговорите в реално време. Ако е деактивирано, ще се показва само пълният отговор.",
+ "title": "Активиране на поточно предаване"
+ },
"historyCount": {
"desc": "Брой исторически съобщения, носени с всяка заявка",
"title": "Брой прикачени съобщения в историята"
diff --git a/locales/de-DE/setting.json b/locales/de-DE/setting.json
index 7aa08c14fdf..c2f4488be95 100644
--- a/locales/de-DE/setting.json
+++ b/locales/de-DE/setting.json
@@ -237,6 +237,10 @@
"title": "Historiennachrichten begrenzen",
"unlimited": "Unbegrenzte Historiennachrichten"
},
+ "enableStreaming": {
+ "desc": "Aktivieren Sie den Streaming-Ausgang, um Antworten in Echtzeit anzuzeigen. Wenn deaktiviert, wird nur die vollständige Antwort angezeigt.",
+ "title": "Streaming-Ausgabe aktivieren"
+ },
"historyCount": {
"desc": "Anzahl der Nachrichten pro Anfrage (einschließlich der neuesten Fragen und Antworten. Jede Frage und Antwort zählt als 1)",
"title": "Anzahl der mitgelieferten Nachrichten"
diff --git a/locales/en-US/setting.json b/locales/en-US/setting.json
index ba1a94d38dc..14d7e1c321b 100644
--- a/locales/en-US/setting.json
+++ b/locales/en-US/setting.json
@@ -237,6 +237,10 @@
"title": "Limit History Message Count",
"unlimited": "Unlimited history message count"
},
+ "enableStreaming": {
+ "desc": "Enable streaming output to display responses in real-time. When disabled, only the complete response is shown.",
+ "title": "Enable Streaming Output"
+ },
"historyCount": {
"desc": "Number of historical messages carried with each request",
"title": "Attached History Message Count"
diff --git a/locales/es-ES/setting.json b/locales/es-ES/setting.json
index c9c7e7c6d0e..b99558e9476 100644
--- a/locales/es-ES/setting.json
+++ b/locales/es-ES/setting.json
@@ -237,6 +237,10 @@
"title": "Limitar número de mensajes históricos",
"unlimited": "Sin límite de mensajes históricos"
},
+ "enableStreaming": {
+ "desc": "Habilita la salida en streaming para mostrar la respuesta en tiempo real. Si se desactiva, solo se mostrará la respuesta completa.",
+ "title": "Habilitar salida en streaming"
+ },
"historyCount": {
"desc": "Número de mensajes incluidos en cada solicitud (incluyendo las preguntas más recientes. Cada pregunta y respuesta se cuenta como 1)",
"title": "Número de mensajes incluidos"
diff --git a/locales/fa-IR/setting.json b/locales/fa-IR/setting.json
index 8663eb6e174..ae82d6b93e6 100644
--- a/locales/fa-IR/setting.json
+++ b/locales/fa-IR/setting.json
@@ -237,6 +237,10 @@
"title": "محدودیت تعداد پیام‌های تاریخی",
"unlimited": "بدون محدودیت در تعداد پیام‌های تاریخی"
},
+ "enableStreaming": {
+ "desc": "فعال‌سازی خروجی جریانی برای نمایش پاسخ‌ها به‌صورت زنده. در صورت غیرفعال بودن، فقط پاسخ کامل نمایش داده می‌شود.",
+ "title": "فعال‌سازی خروجی جریانی"
+ },
"historyCount": {
"desc": "تعداد پیام‌هایی که در هر درخواست ارسال می‌شوند (شامل آخرین سوال نوشته‌شده. هر سوال و پاسخ به‌عنوان 1 محاسبه می‌شود)",
"title": "تعداد پیام‌های همراه"
diff --git a/locales/fr-FR/setting.json b/locales/fr-FR/setting.json
index b1890651006..fe55543e9b3 100644
--- a/locales/fr-FR/setting.json
+++ b/locales/fr-FR/setting.json
@@ -237,6 +237,10 @@
"title": "Limite du nombre de messages historiques",
"unlimited": "Aucune limite sur le nombre de messages historiques"
},
+ "enableStreaming": {
+ "desc": "Activez la diffusion en continu pour afficher les réponses en temps réel. Si désactivé, seule la réponse complète sera affichée.",
+ "title": "Activer la diffusion en continu"
+ },
"historyCount": {
"desc": "Nombre de messages historiques à inclure dans chaque requête",
"title": "Nombre de messages historiques inclus"
diff --git a/locales/it-IT/setting.json b/locales/it-IT/setting.json
index 6f0fd332c2c..07a0a5cbe00 100644
--- a/locales/it-IT/setting.json
+++ b/locales/it-IT/setting.json
@@ -237,6 +237,10 @@
"title": "Limita il numero di messaggi storici",
"unlimited": "Numero illimitato di messaggi storici"
},
+ "enableStreaming": {
+ "desc": "Abilita l'output in streaming per visualizzare la risposta in tempo reale. Se disabilitato, verrà mostrata solo la risposta completa.",
+ "title": "Abilita output in streaming"
+ },
"historyCount": {
"desc": "Numero di messaggi inclusi in ogni richiesta (inclusi gli ultimi messaggi scritti, ogni domanda e risposta conta come 1)",
"title": "Numero di messaggi inclusi"
diff --git a/locales/ja-JP/setting.json b/locales/ja-JP/setting.json
index 836d0675232..8f4ee236a7f 100644
--- a/locales/ja-JP/setting.json
+++ b/locales/ja-JP/setting.json
@@ -237,6 +237,10 @@
"title": "過去メッセージ数を制限する",
"unlimited": "過去メッセージ数を制限しない"
},
+ "enableStreaming": {
+ "desc": "リアルタイムで応答を表示するためにストリーミング出力を有効にします。無効にすると、完全な応答のみが表示されます。",
+ "title": "ストリーミング出力を有効にする"
+ },
"historyCount": {
"desc": "リクエストごとに含まれる過去メッセージの数",
"title": "過去メッセージ数"
diff --git a/locales/ko-KR/setting.json b/locales/ko-KR/setting.json
index b3a590d9f96..9bc7dfe15a6 100644
--- a/locales/ko-KR/setting.json
+++ b/locales/ko-KR/setting.json
@@ -237,6 +237,10 @@
"title": "이전 메시지 수 제한",
"unlimited": "이전 메시지 수 제한 없음"
},
+ "enableStreaming": {
+ "desc": "실시간으로 응답을 표시하려면 스트리밍 출력을 활성화하세요. 비활성화하면 전체 응답만 표시됩니다.",
+ "title": "스트리밍 출력 활성화"
+ },
"historyCount": {
"desc": "요청당 포함되는 이전 메시지 수",
"title": "이전 메시지 수"
diff --git a/locales/nl-NL/setting.json b/locales/nl-NL/setting.json
index 2d387a0a414..36799ada761 100644
--- a/locales/nl-NL/setting.json
+++ b/locales/nl-NL/setting.json
@@ -237,6 +237,10 @@
"title": "Berichtgeschiedenis beperken",
"unlimited": "Onbeperkt aantal berichten in de geschiedenis"
},
+ "enableStreaming": {
+ "desc": "Schakel streaming-uitvoer in om reacties in realtime weer te geven. Als dit is uitgeschakeld, wordt alleen de volledige reactie weergegeven.",
+ "title": "Streaming-uitvoer inschakelen"
+ },
"historyCount": {
"desc": "Aantal berichten dat bij elke aanvraag wordt meegenomen (inclusief de meest recente vraag. Elke vraag en antwoord tellen als 1)",
"title": "Berichtaantal meenemen"
diff --git a/locales/pl-PL/setting.json b/locales/pl-PL/setting.json
index bca01608fa6..54dce9d3abb 100644
--- a/locales/pl-PL/setting.json
+++ b/locales/pl-PL/setting.json
@@ -237,6 +237,10 @@
"title": "Ograniczenie liczby wiadomości w historii",
"unlimited": "Bez limitu wiadomości w historii"
},
+ "enableStreaming": {
+ "desc": "Włącz strumieniowe wyświetlanie odpowiedzi w czasie rzeczywistym. Po wyłączeniu wyświetlana jest tylko pełna odpowiedź.",
+ "title": "Włącz strumieniowe wyświetlanie"
+ },
"historyCount": {
"desc": "Liczba wiadomości przesyłanych w jednym żądaniu (obejmuje najnowsze pytania i odpowiedzi, gdzie każde pytanie i odpowiedź liczy się jako 1)",
"title": "Liczba wiadomości"
diff --git a/locales/pt-BR/setting.json b/locales/pt-BR/setting.json
index cd196ab5e5e..ad1c6e6909a 100644
--- a/locales/pt-BR/setting.json
+++ b/locales/pt-BR/setting.json
@@ -237,6 +237,10 @@
"title": "Limitar número de mensagens de histórico",
"unlimited": "Sem limite de mensagens de histórico"
},
+ "enableStreaming": {
+ "desc": "Ative a saída em fluxo para exibir respostas em tempo real. Quando desativado, apenas a resposta completa será exibida.",
+ "title": "Ativar saída em fluxo"
+ },
"historyCount": {
"desc": "Número de mensagens incluídas em cada solicitação (incluindo a última pergunta feita. Cada pergunta e resposta contam como 1)",
"title": "Número de mensagens incluídas"
diff --git a/locales/ru-RU/setting.json b/locales/ru-RU/setting.json
index 1858b3833d1..eee4f128953 100644
--- a/locales/ru-RU/setting.json
+++ b/locales/ru-RU/setting.json
@@ -237,6 +237,10 @@
"title": "Ограничение истории сообщений",
"unlimited": "Без ограничения истории сообщений"
},
+ "enableStreaming": {
+ "desc": "Включите потоковую передачу для отображения ответа в реальном времени. Если отключено, будет показан только полный ответ.",
+ "title": "Включить потоковую передачу"
+ },
"historyCount": {
"desc": "Количество сообщений, передаваемых с каждым запросом",
"title": "Количество сообщений в истории"
diff --git a/locales/tr-TR/setting.json b/locales/tr-TR/setting.json
index 96f6c53b9c3..e484a9a0ea5 100644
--- a/locales/tr-TR/setting.json
+++ b/locales/tr-TR/setting.json
@@ -237,6 +237,10 @@
"title": "Geçmiş Mesaj Sayısı Sınırlama",
"unlimited": "Sınırsız geçmiş mesaj sayısı"
},
+ "enableStreaming": {
+ "desc": "Yanıtları gerçek zamanlı göstermek için akışlı çıktıyı etkinleştirin. Devre dışı bırakıldığında yalnızca tam yanıt gösterilir.",
+ "title": "Akışlı Çıktıyı Etkinleştir"
+ },
"historyCount": {
"desc": "Her istekle taşınan tarihsel mesaj sayısı",
"title": "Eklenen Geçmiş Mesaj Sayısı"
diff --git a/locales/vi-VN/setting.json b/locales/vi-VN/setting.json
index cadc78cca30..a3025a90acb 100644
--- a/locales/vi-VN/setting.json
+++ b/locales/vi-VN/setting.json
@@ -237,6 +237,10 @@
"title": "Giới hạn số lượng tin nhắn lịch sử",
"unlimited": "Không giới hạn số lượng tin nhắn lịch sử"
},
+ "enableStreaming": {
+ "desc": "Bật phát trực tiếp để hiển thị phản hồi theo thời gian thực. Tắt sẽ chỉ hiển thị phản hồi đầy đủ.",
+ "title": "Bật phát trực tiếp"
+ },
"historyCount": {
"desc": "Số lượng tin nhắn được gửi mỗi lần yêu cầu (bao gồm cả câu hỏi mới nhất. Mỗi câu hỏi và câu trả lời đều tính là 1)",
"title": "Số lượng tin nhắn đi kèm"
diff --git a/locales/zh-CN/setting.json b/locales/zh-CN/setting.json
index d65fb0fa82f..ce602c3a5c8 100644
--- a/locales/zh-CN/setting.json
+++ b/locales/zh-CN/setting.json
@@ -237,6 +237,10 @@
"title": "限制历史消息数",
"unlimited": "不限历史消息数"
},
+ "enableStreaming": {
+ "desc": "启用流式输出以实时显示响应。禁用后仅显示完整响应。",
+ "title": "启用流式输出"
+ },
"historyCount": {
"desc": "每次请求携带的消息数(包括最新编写的提问。每个提问和回答都计算1)",
"title": "附带消息数"
diff --git a/locales/zh-TW/setting.json b/locales/zh-TW/setting.json
index 9234ca5de23..588d907471a 100644
--- a/locales/zh-TW/setting.json
+++ b/locales/zh-TW/setting.json
@@ -237,6 +237,10 @@
"title": "限制歷史訊息數",
"unlimited": "不限歷史訊息數"
},
+ "enableStreaming": {
+ "desc": "啟用串流輸出以即時顯示回應。停用後僅顯示完整回應。",
+ "title": "啟用串流輸出"
+ },
"historyCount": {
"desc": "每次請求攜帶的歷史訊息數",
"title": "附帶歷史訊息數"
diff --git a/packages/const/src/settings/agent.ts b/packages/const/src/settings/agent.ts
index 8b5d6be3b61..7bf78f35794 100644
--- a/packages/const/src/settings/agent.ts
+++ b/packages/const/src/settings/agent.ts
@@ -29,6 +29,7 @@ export const DEFAULT_AGENT_CHAT_CONFIG: LobeAgentChatConfig = {
enableCompressHistory: true,
enableHistoryCount: true,
enableReasoning: false,
+ enableStreaming: true,
historyCount: 20,
reasoningBudgetToken: 1024,
searchFCModel: DEFAULT_AGENT_SEARCH_FC_MODEL,
diff --git a/packages/types/src/agent/chatConfig.ts b/packages/types/src/agent/chatConfig.ts
index 3f63b6fab01..340b3175115 100644
--- a/packages/types/src/agent/chatConfig.ts
+++ b/packages/types/src/agent/chatConfig.ts
@@ -16,6 +16,11 @@ export interface LobeAgentChatConfig {
enableMaxTokens?: boolean;
+ /**
+ * 是否开启流式输出
+ */
+ enableStreaming?: boolean;
+
/**
* 是否开启推理
*/
@@ -68,6 +73,7 @@ export const AgentChatConfigSchema = z.object({
enableMaxTokens: z.boolean().optional(),
enableReasoning: z.boolean().optional(),
enableReasoningEffort: z.boolean().optional(),
+ enableStreaming: z.boolean().optional(),
historyCount: z.number().optional(),
reasoningBudgetToken: z.number().optional(),
searchFCModel: z
diff --git a/src/features/AgentSetting/AgentModal/index.tsx b/src/features/AgentSetting/AgentModal/index.tsx
index 5ae0f9e8664..b1b499913aa 100644
--- a/src/features/AgentSetting/AgentModal/index.tsx
+++ b/src/features/AgentSetting/AgentModal/index.tsx
@@ -31,6 +31,15 @@ const AgentModal = memo(() => {
name: '_modalConfig',
tag: 'model',
},
+ {
+ children: <Switch />,
+ desc: t('settingChat.enableStreaming.desc'),
+ label: t('settingChat.enableStreaming.title'),
+ layout: 'horizontal',
+ minWidth: undefined,
+ name: 'enableStreaming',
+ valuePropName: 'checked',
+ },
{
children: <SliderWithInput max={2} min={0} step={0.1} />,
desc: t('settingModel.temperature.desc'),
diff --git a/src/locales/default/setting.ts b/src/locales/default/setting.ts
index fd4d88514cb..c89329ac5af 100644
--- a/src/locales/default/setting.ts
+++ b/src/locales/default/setting.ts
@@ -241,6 +241,10 @@ export default {
title: '限制历史消息数',
unlimited: '不限历史消息数',
},
+ enableStreaming: {
+ desc: '启用流式输出以实时显示响应。禁用后仅显示完整响应。',
+ title: '启用流式输出',
+ },
historyCount: {
desc: '每次请求携带的消息数(包括最新编写的提问。每个提问和回答都计算1)',
title: '附带消息数',
diff --git a/src/services/chat.ts b/src/services/chat.ts
index ca8999b3ff2..9b1eab6d265 100644
--- a/src/services/chat.ts
+++ b/src/services/chat.ts
@@ -365,8 +365,15 @@ class ChatService {
? 'responses'
: undefined;
+ // Get the chat config to check streaming preference
+ const chatConfig = agentChatConfigSelectors.currentChatConfig(getAgentStoreState());
+
const payload = merge(
- { model: DEFAULT_AGENT_CONFIG.model, stream: true, ...DEFAULT_AGENT_CONFIG.params },
+ {
+ model: DEFAULT_AGENT_CONFIG.model,
+ stream: chatConfig.enableStreaming !== false, // Default to true if not set
+ ...DEFAULT_AGENT_CONFIG.params,
+ },
{ ...res, apiMode, model },
);
diff --git a/src/store/agent/slices/chat/selectors/__snapshots__/agent.test.ts.snap b/src/store/agent/slices/chat/selectors/__snapshots__/agent.test.ts.snap
index 06e0fba1081..e7ebd149a24 100644
--- a/src/store/agent/slices/chat/selectors/__snapshots__/agent.test.ts.snap
+++ b/src/store/agent/slices/chat/selectors/__snapshots__/agent.test.ts.snap
@@ -9,6 +9,7 @@ exports[`agentSelectors > defaultAgentConfig > should merge DEFAULT_AGENT_CONFIG
"enableCompressHistory": true,
"enableHistoryCount": true,
"enableReasoning": false,
+ "enableStreaming": true,
"historyCount": 20,
"reasoningBudgetToken": 1024,
"searchFCModel": {
diff --git a/src/store/user/slices/settings/selectors/__snapshots__/settings.test.ts.snap b/src/store/user/slices/settings/selectors/__snapshots__/settings.test.ts.snap
index 2daaf8e1c59..e97cc8dc7c1 100644
--- a/src/store/user/slices/settings/selectors/__snapshots__/settings.test.ts.snap
+++ b/src/store/user/slices/settings/selectors/__snapshots__/settings.test.ts.snap
@@ -112,6 +112,7 @@ exports[`settingsSelectors > defaultAgent > should merge DEFAULT_AGENT and s.set
"enableCompressHistory": true,
"enableHistoryCount": true,
"enableReasoning": false,
+ "enableStreaming": true,
"historyCount": 20,
"reasoningBudgetToken": 1024,
"searchFCModel": {
@@ -156,6 +157,7 @@ exports[`settingsSelectors > defaultAgentConfig > should merge DEFAULT_AGENT_CON
"enableCompressHistory": true,
"enableHistoryCount": true,
"enableReasoning": false,
+ "enableStreaming": true,
"historyCount": 20,
"reasoningBudgetToken": 1024,
"searchFCModel": {