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

* support non-stream mode

* improve streaming part

* fix tests
This commit is contained in:
Arvin Xu
2025-08-30 02:46:06 +08:00
committed by GitHub
parent e56e475331
commit ce623bb280
25 changed files with 103 additions and 1 deletions
+4
View File
@@ -237,6 +237,10 @@
"title": "تحديد عدد الرسائل التاريخية",
"unlimited": "غير محدود"
},
"enableStreaming": {
"desc": "تمكين الإخراج المتدفق لعرض الاستجابات في الوقت الفعلي. عند التعطيل، يتم عرض الاستجابة الكاملة فقط.",
"title": "تمكين الإخراج المتدفق"
},
"historyCount": {
"desc": "عدد الرسائل التي يتم إرفاقها في كل طلب (تشمل الأسئلة والأجوبة الجديدة. يُحسب كل سؤال وجواب كرسالة واحدة)",
"title": "عدد الرسائل المرفقة"
+4
View File
@@ -237,6 +237,10 @@
"title": "Ограничаване на броя на съобщенията в историята",
"unlimited": "Неограничен брой съобщения в историята"
},
"enableStreaming": {
"desc": "Активирайте поточно предаване, за да показвате отговорите в реално време. Ако е деактивирано, ще се показва само пълният отговор.",
"title": "Активиране на поточно предаване"
},
"historyCount": {
"desc": "Брой исторически съобщения, носени с всяка заявка",
"title": "Брой прикачени съобщения в историята"
+4
View File
@@ -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"
+4
View File
@@ -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"
+4
View File
@@ -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"
+4
View File
@@ -237,6 +237,10 @@
"title": "محدودیت تعداد پیام‌های تاریخی",
"unlimited": "بدون محدودیت در تعداد پیام‌های تاریخی"
},
"enableStreaming": {
"desc": "فعال‌سازی خروجی جریانی برای نمایش پاسخ‌ها به‌صورت زنده. در صورت غیرفعال بودن، فقط پاسخ کامل نمایش داده می‌شود.",
"title": "فعال‌سازی خروجی جریانی"
},
"historyCount": {
"desc": "تعداد پیام‌هایی که در هر درخواست ارسال می‌شوند (شامل آخرین سوال نوشته‌شده. هر سوال و پاسخ به‌عنوان 1 محاسبه می‌شود)",
"title": "تعداد پیام‌های همراه"
+4
View File
@@ -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"
+4
View File
@@ -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"
+4
View File
@@ -237,6 +237,10 @@
"title": "過去メッセージ数を制限する",
"unlimited": "過去メッセージ数を制限しない"
},
"enableStreaming": {
"desc": "リアルタイムで応答を表示するためにストリーミング出力を有効にします。無効にすると、完全な応答のみが表示されます。",
"title": "ストリーミング出力を有効にする"
},
"historyCount": {
"desc": "リクエストごとに含まれる過去メッセージの数",
"title": "過去メッセージ数"
+4
View File
@@ -237,6 +237,10 @@
"title": "이전 메시지 수 제한",
"unlimited": "이전 메시지 수 제한 없음"
},
"enableStreaming": {
"desc": "실시간으로 응답을 표시하려면 스트리밍 출력을 활성화하세요. 비활성화하면 전체 응답만 표시됩니다.",
"title": "스트리밍 출력 활성화"
},
"historyCount": {
"desc": "요청당 포함되는 이전 메시지 수",
"title": "이전 메시지 수"
+4
View File
@@ -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"
+4
View File
@@ -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"
+4
View File
@@ -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"
+4
View File
@@ -237,6 +237,10 @@
"title": "Ограничение истории сообщений",
"unlimited": "Без ограничения истории сообщений"
},
"enableStreaming": {
"desc": "Включите потоковую передачу для отображения ответа в реальном времени. Если отключено, будет показан только полный ответ.",
"title": "Включить потоковую передачу"
},
"historyCount": {
"desc": "Количество сообщений, передаваемых с каждым запросом",
"title": "Количество сообщений в истории"
+4
View File
@@ -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ı"
+4
View File
@@ -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"
+4
View File
@@ -237,6 +237,10 @@
"title": "限制历史消息数",
"unlimited": "不限历史消息数"
},
"enableStreaming": {
"desc": "启用流式输出以实时显示响应。禁用后仅显示完整响应。",
"title": "启用流式输出"
},
"historyCount": {
"desc": "每次请求携带的消息数(包括最新编写的提问。每个提问和回答都计算1)",
"title": "附带消息数"
+4
View File
@@ -237,6 +237,10 @@
"title": "限制歷史訊息數",
"unlimited": "不限歷史訊息數"
},
"enableStreaming": {
"desc": "啟用串流輸出以即時顯示回應。停用後僅顯示完整回應。",
"title": "啟用串流輸出"
},
"historyCount": {
"desc": "每次請求攜帶的歷史訊息數",
"title": "附帶歷史訊息數"
+1
View File
@@ -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,
+6
View File
@@ -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
@@ -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'),
+4
View File
@@ -241,6 +241,10 @@ export default {
title: '限制历史消息数',
unlimited: '不限历史消息数',
},
enableStreaming: {
desc: '启用流式输出以实时显示响应。禁用后仅显示完整响应。',
title: '启用流式输出',
},
historyCount: {
desc: '每次请求携带的消息数(包括最新编写的提问。每个提问和回答都计算1)',
title: '附带消息数',
+8 -1
View File
@@ -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 },
);
@@ -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": {
@@ -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": {