diff --git a/src/components/ModelSelect/index.vue b/src/components/ModelSelect/index.vue index 8456586..8d194f5 100644 --- a/src/components/ModelSelect/index.vue +++ b/src/components/ModelSelect/index.vue @@ -111,6 +111,7 @@ function handleClick(item: GetSessionListVO) { .model-select-box { color: var(--el-color-primary, #409eff); border: 1px solid var(--el-color-primary, #409eff); + background: var(--el-color-primary-light-9, rgb(235.9, 245.3, 255)); border-radius: 10px; } diff --git a/src/layouts/index-1.vue b/src/layouts/index-1.vue deleted file mode 100644 index 9508839..0000000 --- a/src/layouts/index-1.vue +++ /dev/null @@ -1,79 +0,0 @@ - - - diff --git a/src/pages/chat/layouts/chatWithId/index.vue b/src/pages/chat/layouts/chatWithId/index.vue index bce0d1d..4c8ad85 100644 --- a/src/pages/chat/layouts/chatWithId/index.vue +++ b/src/pages/chat/layouts/chatWithId/index.vue @@ -43,6 +43,8 @@ const bubbleListRef = ref(null); const isLoading = ref(false); // 记录发送的返回 let sendRequest: HookFetchRequest | null = null; +// 记录进入思考中 +let isThinking = false; watch( () => route.params?.id, @@ -95,23 +97,47 @@ function handleDataChunk(chunk: AnyObject) { // 开始思考链状态 bubbleItems.value[bubbleItems.value.length - 1].thinkingStatus = 'thinking'; bubbleItems.value[bubbleItems.value.length - 1].loading = true; + bubbleItems.value[bubbleItems.value.length - 1].thinlCollapse = true; if (bubbleItems.value.length) { bubbleItems.value[bubbleItems.value.length - 1].reasoning_content += reasoningChunk; } } + // 另一种思考中形式,content中有 的格式 + // 一开始匹配到 开始,匹配到 结束,并处理标签中的内容为思考内容 const parsedChunk = chunk.choices?.[0].delta.content; if (parsedChunk) { - // 结束 思考链状态 - bubbleItems.value[bubbleItems.value.length - 1].thinkingStatus = 'end'; - bubbleItems.value[bubbleItems.value.length - 1].loading = false; - - if (bubbleItems.value.length) { - bubbleItems.value[bubbleItems.value.length - 1].content += parsedChunk; + const thinkStart = parsedChunk.includes(''); + const thinkEnd = parsedChunk.includes(''); + if (thinkStart) { + isThinking = true; + } + if (thinkEnd) { + isThinking = false; + } + if (isThinking) { + // 开始思考链状态 + bubbleItems.value[bubbleItems.value.length - 1].thinkingStatus = 'thinking'; + bubbleItems.value[bubbleItems.value.length - 1].loading = true; + bubbleItems.value[bubbleItems.value.length - 1].thinlCollapse = true; + if (bubbleItems.value.length) { + bubbleItems.value[bubbleItems.value.length - 1].reasoning_content += parsedChunk + .replace('', '') + .replace('', ''); + } + } + else { + // 结束 思考链状态 + bubbleItems.value[bubbleItems.value.length - 1].thinkingStatus = 'end'; + bubbleItems.value[bubbleItems.value.length - 1].loading = false; + if (bubbleItems.value.length) { + bubbleItems.value[bubbleItems.value.length - 1].content += parsedChunk; + } } } } catch (err) { + // 这里如果使用了中断,会有报错,可以忽略不管 console.error('解析数据时出错:', err); } } @@ -189,6 +215,7 @@ function addMessage(message: string, isUser: boolean) { content: message || '', reasoning_content: '', thinkingStatus: 'start', + thinlCollapse: false, }; bubbleItems.value.push(obj); } @@ -226,6 +253,7 @@ watch(