Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
fix: show answer generation status after retrieval
ttommybot747cbcbc02ed
diff --git a/frontend/src/i18n/embed.ts b/frontend/src/i18n/embed.tsindex d644d7431..4ffc3943b 100644--- a/frontend/src/i18n/embed.ts+++ b/frontend/src/i18n/embed.ts@@ -106,6 +106,8 @@ const messages = {"unableToGetKnowledgeBaseId": "无法获取知识库ID","summaryInProgress": "正在总结答案……","thinkingAlt": "正在思考",+ "preparingAnswer": "正在准备回答…",+ "connectingModelAndGeneratingAnswer": "正在连接模型并生成回答…","deepThoughtCompleted": "已深度思考","deepThoughtAlt": "深度思考完成","referencesTitle": "参考了{count}个相关内容",@@ -596,6 +598,8 @@ const messages = {"unableToGetKnowledgeBaseId": "Unable to get knowledge base ID","summaryInProgress": "Summarizing answer…","thinkingAlt": "Thinking in progress",+ "preparingAnswer": "Preparing an answer…",+ "connectingModelAndGeneratingAnswer": "Connecting to the model and generating an answer…","deepThoughtCompleted": "Deep thinking completed","deepThoughtAlt": "Deep thinking finished","referencesTitle": "Referenced {count} related item(s)",@@ -1048,6 +1052,8 @@ const koEmbedPublish = {followUpQuestions: '이어서 질문',followUpQuestionsLoading: '추천 질문 로딩 중',thinkingAlt: '생각 중',+ preparingAnswer: '답변을 준비하고 있습니다…',+ connectingModelAndGeneratingAnswer: '모델에 연결하여 답변을 생성하고 있습니다…',refreshSuggestedQuestions: '다른 질문',imageTooMany: '이미지는 최대 5장까지 업로드할 수 있습니다',imageTypeSizeError: 'JPG/PNG/GIF/WEBP만 지원하며, 각 파일은 10MB 이하여야 합니다',@@ -1136,6 +1142,8 @@ const ruEmbedPublish = {followUpQuestions: 'Спрашивайте дальше',followUpQuestionsLoading: 'Загрузка рекомендуемых вопросов',thinkingAlt: 'Обдумывание...',+ preparingAnswer: 'Подготовка ответа…',+ connectingModelAndGeneratingAnswer: 'Подключение к модели и создание ответа…',refreshSuggestedQuestions: 'Ещё',imageTooMany: 'Можно загрузить не более 5 изображений',imageTypeSizeError: 'Поддерживаются только JPG/PNG/GIF/WEBP, каждый файл до 10 МБ',diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.tsindex 2e26df758..00f1720b3 100755--- a/frontend/src/i18n/locales/en-US.ts+++ b/frontend/src/i18n/locales/en-US.ts@@ -2558,6 +2558,8 @@ export default {refreshSuggestedQuestions: 'More',thinking: 'Thinking...',thinkingAlt: 'Thinking in progress',+ preparingAnswer: 'Preparing an answer…',+ connectingModelAndGeneratingAnswer: 'Connecting to the model and generating an answer…',deepThoughtCompleted: 'Deep thinking completed',deepThoughtAlt: 'Deep thinking finished',referencesTitle: 'Referenced {count} related item(s)',diff --git a/frontend/src/i18n/locales/ko-KR.ts b/frontend/src/i18n/locales/ko-KR.tsindex bd77d2e22..37ed3ef65 100755--- a/frontend/src/i18n/locales/ko-KR.ts+++ b/frontend/src/i18n/locales/ko-KR.ts@@ -3046,6 +3046,8 @@ export default {refreshSuggestedQuestions: '다른 질문',thinking: '생각 중...',thinkingAlt: '생각 중',+ preparingAnswer: '답변을 준비하고 있습니다…',+ connectingModelAndGeneratingAnswer: '모델에 연결하여 답변을 생성하고 있습니다…',deepThoughtCompleted: '심층 분석 완료',deepThoughtAlt: '심층 분석 완료',referencesTitle: '{count}개의 관련 내용 참조',diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.tsindex 7930731c4..3d1f5f7a0 100755--- a/frontend/src/i18n/locales/ru-RU.ts+++ b/frontend/src/i18n/locales/ru-RU.ts@@ -3046,6 +3046,8 @@ export default {refreshSuggestedQuestions: 'Ещё',thinking: 'Думаю...',thinkingAlt: 'Обдумывание...',+ preparingAnswer: 'Подготовка ответа…',+ connectingModelAndGeneratingAnswer: 'Подключение к модели и создание ответа…',deepThoughtCompleted: 'Глубокий анализ завершён',deepThoughtAlt: 'Глубокий анализ',referencesTitle: 'Использовано {count} связанного материала',diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.tsindex c80b842ff..285aa678a 100755--- a/frontend/src/i18n/locales/zh-CN.ts+++ b/frontend/src/i18n/locales/zh-CN.ts@@ -3046,6 +3046,8 @@ export default {refreshSuggestedQuestions: '换一批',thinking: '思考中...',thinkingAlt: '正在思考',+ preparingAnswer: '正在准备回答…',+ connectingModelAndGeneratingAnswer: '正在连接模型并生成回答…',deepThoughtCompleted: '已深度思考',deepThoughtAlt: '深度思考完成',referencesTitle: '参考了{count}个相关内容',diff --git a/frontend/src/utils/rag-pipeline-state.test.ts b/frontend/src/utils/rag-pipeline-state.test.tsnew file mode 100644index 000000000..3f44055b2--- /dev/null+++ b/frontend/src/utils/rag-pipeline-state.test.ts@@ -0,0 +1,52 @@+import assert from 'node:assert/strict'+import test from 'node:test'+import { shouldShowRagModelAnswerWait } from './rag-pipeline-state.ts'++const completedRetrieval = {+ isCompleted: false,+ hasAnswer: false,+ hasThinkingEvent: false,+ stepCount: 2,+ allStepsDone: true,+ hasCompletedRetrievalStep: true,+}++test('shows the model-answer wait state after the RAG pipeline finishes', () => {+ assert.equal(shouldShowRagModelAnswerWait(completedRetrieval), true)+})++test('does not show the model-answer wait state while a pipeline step is pending', () => {+ assert.equal(shouldShowRagModelAnswerWait({+ ...completedRetrieval,+ allStepsDone: false,+ }), false)+})++test('does not show the model-answer wait state before pipeline events arrive', () => {+ assert.equal(shouldShowRagModelAnswerWait({+ ...completedRetrieval,+ stepCount: 0,+ }), false)+})++test('does not mistake a completed pre-retrieval step for the model-answer wait', () => {+ assert.equal(shouldShowRagModelAnswerWait({+ ...completedRetrieval,+ hasCompletedRetrievalStep: false,+ }), false)+})++test('hides the model-answer wait state when thinking, answer, or completion arrives', () => {+ assert.equal(shouldShowRagModelAnswerWait({+ ...completedRetrieval,+ hasThinkingEvent: true,+ }), false)+ assert.equal(shouldShowRagModelAnswerWait({+ ...completedRetrieval,+ hasAnswer: true,+ }), false)+ assert.equal(shouldShowRagModelAnswerWait({+ ...completedRetrieval,+ isCompleted: true,+ }), false)+})diff --git a/frontend/src/utils/rag-pipeline-state.ts b/frontend/src/utils/rag-pipeline-state.tsnew file mode 100644index 000000000..bd063f0b4--- /dev/null+++ b/frontend/src/utils/rag-pipeline-state.ts@@ -0,0 +1,23 @@+export interface RagModelAnswerWaitState {+ isCompleted: boolean+ hasAnswer: boolean+ hasThinkingEvent: boolean+ stepCount: number+ allStepsDone: boolean+ hasCompletedRetrievalStep: boolean+}++/**+ * Show a model-answer wait state only in the quiet gap after every visible RAG+ * pipeline step has finished and before the model emits thinking or answer text.+ */+export function shouldShowRagModelAnswerWait(state: RagModelAnswerWaitState): boolean {+ return (+ !state.isCompleted &&+ !state.hasAnswer &&+ !state.hasThinkingEvent &&+ state.stepCount > 0 &&+ state.allStepsDone &&+ state.hasCompletedRetrievalStep+ )+}diff --git a/frontend/src/views/chat/components/RagPipelineProgress.style.test.mjs b/frontend/src/views/chat/components/RagPipelineProgress.style.test.mjsindex 75594e2d2..712a255d6 100644--- a/frontend/src/views/chat/components/RagPipelineProgress.style.test.mjs+++ b/frontend/src/views/chat/components/RagPipelineProgress.style.test.mjs@@ -50,7 +50,7 @@ test('rag pipeline opens references from search steps and the drawer composable'test('rag pipeline uses a native pending step and lets the thinking title shimmer while pending', () => {assert.match(source, /showPrePipelineWait/)assert.match(source, /class="action-card action-pending"/)- assert.match(source, /t\('chat\.thinkingAlt'\)/)+ assert.match(source, /t\('chat\.preparingAnswer'\)/)assert.match(source, /showThinkingStep/)assert.match(source, /'action-pending': thinkingPending/)assert.match(source, /hasThinkingEvent/)@@ -58,6 +58,13 @@ test('rag pipeline uses a native pending step and lets the thinking title shimmeassert.doesNotMatch(source, /showActivityIndicator/)})+test('rag pipeline shows a pending model-answer step after retrieval completes', () => {+ assert.match(source, /showModelAnswerWait/)+ assert.match(source, /shouldShowRagModelAnswerWait/)+ assert.match(source, /t\('chat\.connectingModelAndGeneratingAnswer'\)/)+ assert.match(source, /rag-model-wait-step/)+})+test('done row appears only after the full turn completes', () => {assert.match(source, /const showDoneRow = computed\(\(\) => \{[\s\S]*hasAnswer\.value/)})diff --git a/frontend/src/views/chat/components/RagPipelineProgress.vue b/frontend/src/views/chat/components/RagPipelineProgress.vueindex e642459a2..babb464a5 100644--- a/frontend/src/views/chat/components/RagPipelineProgress.vue+++ b/frontend/src/views/chat/components/RagPipelineProgress.vue@@ -8,7 +8,7 @@<div class="action-header no-results"><div class="action-title"><t-icon class="action-title-icon" name="lightbulb" />- <span class="action-name">{{ t('chat.thinkingAlt') }}</span>+ <span class="action-name">{{ t('chat.preparingAnswer') }}</span></div></div></div>@@ -20,6 +20,7 @@<div v-for="(step, index) in steps" :key="step.id" class="tree-child" :class="{'tree-child-last':!showDoneRow+ && !showModelAnswerWait&& !showThinkingStep&& index === steps.length - 1,}">@@ -52,6 +53,27 @@</div></div>+ <div+ v-if="showModelAnswerWait"+ class="tree-child tree-child-last streaming-loading-node rag-model-wait-step"+ role="status"+ aria-live="polite"+ >+ <div class="tree-branch" />+ <div class="tree-child-content">+ <div class="tool-event">+ <div class="action-card action-pending">+ <div class="action-header no-results">+ <div class="action-title">+ <t-icon class="action-title-icon" name="lightbulb" />+ <span class="action-name">{{ t('chat.connectingModelAndGeneratingAnswer') }}</span>+ </div>+ </div>+ </div>+ </div>+ </div>+ </div>+<div v-if="showThinkingStep" class="tree-child rag-thinking-step":class="{ 'tree-child-last': !showDoneRow }"><div class="tree-branch" />@@ -188,7 +210,7 @@</template><script setup lang="ts">-import { computed, nextTick, ref, watch } from 'vue'+import { computed, nextTick, onBeforeUnmount, ref, watch } from 'vue'import { useI18n } from 'vue-i18n'import { getAgentToolIconName } from '@/utils/agent-tool-icons'import {@@ -200,6 +222,7 @@ import { getAttachmentParsingSummaryHtml } from '@/utils/attachmentParsingDisplaimport { RAG_TIMELINE_TOOL_NAMES } from '@/utils/rag-pipeline-history'import { useChatReferencesDrawer } from '@/composables/useChatReferencesDrawer'import { buildReferenceSections } from '@/utils/referenceSources'+import { shouldShowRagModelAnswerWait } from '@/utils/rag-pipeline-state'const props = defineProps<{session?: {@@ -217,6 +240,8 @@ const referencesDrawer = useChatReferencesDrawer()const userExpanded = ref(false)const thinkingExpanded = ref(true)const rootElement = ref<HTMLElement | null>(null)+const showModelAnswerWait = ref(false)+let modelAnswerWaitTimer: ReturnType<typeof setTimeout> | undefinedconst thinkingContent = computed(() => {const stream = props.session?.agentEventStream@@ -289,6 +314,7 @@ const steps = computed(() => {return {id: String(event.tool_call_id || `${toolName}-${event.timestamp || 0}`),+ toolName,pending,iconName: getAgentToolIconName(toolName, searchSource),title: getRagPipelineStepTitle(t, {@@ -308,6 +334,21 @@ const allStepsDone = computed(() => steps.value.length > 0 && steps.value.every((step) => !step.pending),)+const hasCompletedRetrievalStep = computed(() => steps.value.some(+ (step) =>+ (step.toolName === 'knowledge_search' || step.toolName === 'search_knowledge') &&+ !step.pending,+))++const shouldShowModelAnswerWait = computed(() => shouldShowRagModelAnswerWait({+ isCompleted: Boolean(props.session?.is_completed),+ hasAnswer: hasAnswer.value,+ hasThinkingEvent: hasThinkingEvent.value,+ stepCount: steps.value.length,+ allStepsDone: allStepsDone.value,+ hasCompletedRetrievalStep: hasCompletedRetrievalStep.value,+}))+const showCollapsedRoot = computed(() =>(hasAnswer.value || Boolean(props.session?.is_completed)) &&@@ -422,6 +463,27 @@ watch(thinkingPending, (pending) => {}})+watch(shouldShowModelAnswerWait, (shouldShow) => {+ if (modelAnswerWaitTimer) {+ clearTimeout(modelAnswerWaitTimer)+ modelAnswerWaitTimer = undefined+ }++ if (!shouldShow) {+ showModelAnswerWait.value = false+ return+ }++ // Avoid flashing the model-wait row when the first answer token arrives+ // immediately after retrieval completes.+ modelAnswerWaitTimer = setTimeout(() => {+ modelAnswerWaitTimer = undefined+ if (shouldShowModelAnswerWait.value) {+ showModelAnswerWait.value = true+ }+ }, 250)+}, { immediate: true })+watch(hasAnswer, (answered) => {if (answered && hasThinking.value) {thinkingExpanded.value = false@@ -437,6 +499,10 @@ watch(thinkingExpanded, (expanded) => {if (!expanded || !isThinkingStreaming.value) returnscrollThinkingDetailToBottom()})++onBeforeUnmount(() => {+ if (modelAnswerWaitTimer) clearTimeout(modelAnswerWaitTimer)+})</script><style scoped lang="less">