Merge branch 'dev' into hugo

This commit is contained in:
hugo committed 2026-06-23 11:22:39 +08:00
commit d5928b42f3
63 files changed
+5759 -1493

No files matched your search

@@ -3,7 +3,9 @@
* SSE 流式对话核心:消息列表、runs、发送与接收。
*/
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { getAuthHeaders } from '@/shared/utils/auth';
import { applyStreamErrorToMessage, type StreamErrorLabels } from '../utils/streamErrorMessage';
import type { ChatMessage, ChatRun, RetrieverResource } from '../types/chat.types';
const normalizeResources = (resources: unknown) => {
@@ -114,6 +116,7 @@ const applyEventMetadata = (msg: ChatMessage, data: Record<string, unknown>) =>
};
export function useChat() {
const { t } = useI18n();
const messages = ref<ChatMessage[]>([]);
const isThinking = ref(false);
const viewId = ref(0);
@@ -173,6 +176,13 @@ export function useChat() {
return String(message ?? 'Unknown error');
};
const streamErrorLabels = (): StreamErrorLabels => ({
networkDisconnectedEmpty: t('chat.streamError.networkDisconnectedEmpty'),
partialInterrupted: t('chat.streamError.partialInterrupted'),
upstreamDisconnected: t('chat.streamError.upstreamDisconnected'),
generic: t('chat.streamError.generic'),
});
const sendMessage = async (
query: string,
agentId: number,
@@ -320,7 +330,7 @@ export function useChat() {
} else if (eventName === 'error') {
const botMsg = ensureBotMessage();
if (!botMsg) continue;
botMsg.content += `\n[Error: ${formatStreamError(data.message)}]`;
applyStreamErrorToMessage(botMsg, formatStreamError(data.message), streamErrorLabels());
run.status = 'error';
if (messages.value === runMessages) isThinking.value = false;
} else if (typeof data.answer === 'string' && data.answer.length > 0) {
@@ -342,7 +352,7 @@ export function useChat() {
const botMsg = ensureBotMessage();
if (botMsg) {
const message = e instanceof Error ? e.message : 'Network Issue';
botMsg.content += `\n[Error: ${message}]`;
applyStreamErrorToMessage(botMsg, message, streamErrorLabels());
}
} finally {
if (messages.value === runMessages) {
@@ -1,4 +1,4 @@
/**
/**
* features/chat/composables/useChatAgent.ts
* 当前 Agent 元数据、知识库选项、推荐问题与用户可切换 Agent 列表。
*/
@@ -96,8 +96,9 @@ export function useChatAgent(options: UseChatAgentOptions) {
const kbDropdownDisabled = computed(() => availableKbOptions.value.length <= 1);
watch(canSelectErpKnowledgeBase, (allowed) => {
// 固资管理默认先走企业知识库,用户可手动切换到 ERP 知识库。
if (allowed) {
selectedKb.value = ERP_KB;
selectedKb.value = DEFAULT_KB;
return;
}
if (selectedKb.value === ERP_KB) {