diff --git a/src/store/conversation.ts b/src/store/conversation.ts index 492821d98f3cb94270b9faedad3b9bb27d9fd741..ff90b6cb98855dcdb1db0885da9a0ccbf19d419d 100644 --- a/src/store/conversation.ts +++ b/src/store/conversation.ts @@ -82,6 +82,22 @@ export const useSessionStore = defineStore('conversation', () => { const appList = ref(); // ai回复是否还在生成中 const isAnswerGenerating = ref(false); + /** + * 将所有获取的数据进行data: \n\n 分割只保留有效信息,更容易处理最后的状态码 + * @param input + * { + **/ + function splitDataString(input) { + if (input.includes('"data: ')) { + return [input]; + } + const parts = input.split(/data: /g).filter(part => part.trim() !== ''); + if (input.startsWith('data: ')) { + return parts.map(part => 'data: ' + part); + } else { + return [parts[0], ...parts.slice(1).map(part => 'data: ' + part)]; + } +} /** * 请求流式数据 * @param params @@ -240,7 +256,6 @@ export const useSessionStore = defineStore('conversation', () => { } const { done, value } = await reader.read(); const decodedValue = addItem + decoder.decode(value, { stream: true }); - if (done) { if (excelPath.value.length > 0) { conversationItem.message[conversationItem.currentInd] += @@ -255,10 +270,12 @@ export const useSessionStore = defineStore('conversation', () => { } break; } + if (decodedValue.includes('data: [DONE]')) { + isEnd = true; + continue; + } // 同一时间戳传来的decodeValue是含有三条信息的合并,so需要分割 - const lines = decodedValue.split('data:'); - // 删除第一个空字符串 - lines.shift(); + const lines = splitDataString(decodedValue); lines.forEach((line) => { // 这里json解析 const message = Object( diff --git a/src/views/styles/createApp.scss b/src/views/styles/createApp.scss index f11e6f6a93648671f7305b2564da7ce3a8af0995..e8f94c4595e63dd9ba12c0dadbf3cfca6d572999 100644 --- a/src/views/styles/createApp.scss +++ b/src/views/styles/createApp.scss @@ -11,7 +11,6 @@ display: flex; position: relative; align-items: center; - min-width: 1628px; .createAppContainerMenu { display: flex; gap: 16px; @@ -81,7 +80,6 @@ } .createAppContainerMain { - min-width: 1200px; margin-top: 16px; padding: 24px 24px 24px 16px; display: flex; @@ -94,7 +92,6 @@ display: flex; gap: 24px; flex: 1; - min-width: 1628px; max-height: calc(100% - 112px); margin-top: 16px; } diff --git a/src/views/styles/workFlowArrange.scss b/src/views/styles/workFlowArrange.scss index f0c25be0d8536d6a3303a4e453249b28e3b682e8..ce21161c2ded13f8309d976c17f7283c7ac623e8 100644 --- a/src/views/styles/workFlowArrange.scss +++ b/src/views/styles/workFlowArrange.scss @@ -134,7 +134,7 @@ .workFlowContainerRight { flex: 1; - min-width: 1292px; + // min-width: 1292px; background-color: var(--flow-canvas-bg); border-radius: 8px; } diff --git a/src/views/styles/workFlowDebug.scss b/src/views/styles/workFlowDebug.scss index f1070ea1309663b567e96d57e6fd7cec45f5ad87..0b5eea2c8357b5653398c65056d4d1d74f99c30b 100644 --- a/src/views/styles/workFlowDebug.scss +++ b/src/views/styles/workFlowDebug.scss @@ -1,5 +1,5 @@ .workFlowDebug { - width: 700px; + width: 40%; height: 100%; position: absolute; right: 0;