si@aidatagov.com 2 weeks ago
parent
commit
2b3e5c6118
  1. 2
      vue-fastapi-frontend/src/api/aichat/aichat.js
  2. 2
      vue-fastapi-frontend/src/views/aichat/MdRenderer.vue
  3. 7
      vue-fastapi-frontend/src/views/aichat/aichat.vue

2
vue-fastapi-frontend/src/api/aichat/aichat.js

@ -23,7 +23,7 @@ export function getChatList(data) {
} }
export function postChatMessage(data,signal) { export function postChatMessage(data,signal) {
return postStream('/aichat-api/robot/robot_chat',data,signal) return postStream('/aichat-api/datagov_assist',data,signal)
} }
export function DeleteChatSession(sessionId) { export function DeleteChatSession(sessionId) {

2
vue-fastapi-frontend/src/views/aichat/MdRenderer.vue

@ -21,7 +21,7 @@
</div> </div>
</div> </div>
<div v-if="item.type === 'router'" style="width: 100%;margin-top: 5px"> <div v-if="item.type === 'router'" style="width: 100%;margin-top: 5px">
<el-link :underline="false" @click="jumpToPath(item.content)">{{'跳转'+ item.content.name}}</el-link> <el-link :underline="false" type="primary" @click="jumpToPath(item.content)">{{'点击跳转'+ item.content.name}}</el-link>
</div> </div>
<div v-else style="width: 100%;margin-top: 5px"> <div v-else style="width: 100%;margin-top: 5px">
<markdown :markdown-string="item.content"></markdown> <markdown :markdown-string="item.content"></markdown>

7
vue-fastapi-frontend/src/views/aichat/aichat.vue

@ -494,7 +494,6 @@ const getWrite = (reader) => {
if (done) return; if (done) return;
const decoder = new TextDecoder('utf-8'); const decoder = new TextDecoder('utf-8');
let str = decoder.decode(value, { stream: true }); let str = decoder.decode(value, { stream: true });
console.log(str)
tempResult += str; tempResult += str;
// 2使 // 2使
@ -524,7 +523,7 @@ const getWrite = (reader) => {
const processChunk = (chunk) => { const processChunk = (chunk) => {
const lastMsg = chatList.value[chatList.value.length - 1]; const lastMsg = chatList.value[chatList.value.length - 1];
console.log(chunk)
// 5 // 5
if (chunk.docs?.length) { if (chunk.docs?.length) {
lastMsg.content.push({ content: chunk.docs, type: "docs" }); lastMsg.content.push({ content: chunk.docs, type: "docs" });
@ -534,7 +533,7 @@ const getWrite = (reader) => {
lastMsg.content.push({ content: chunk.html_image, type: "html_image" }); lastMsg.content.push({ content: chunk.html_image, type: "html_image" });
} else if (chunk.table?.length) { } else if (chunk.table?.length) {
lastMsg.content.push({ content: chunk.table, type: "table" }); lastMsg.content.push({ content: chunk.table, type: "table" });
} else if (chunk.router?.length) { } else if (chunk.router) {
lastMsg.content.push({ content: chunk.router, type: "router" }); lastMsg.content.push({ content: chunk.router, type: "router" });
} else if (chunk.choices?.length) { } else if (chunk.choices?.length) {
// 6 // 6
@ -547,7 +546,6 @@ const getWrite = (reader) => {
? content.replace(/\n{2,}/g, '\n\n') ? content.replace(/\n{2,}/g, '\n\n')
: content.replace(/\n/g, ' '); : content.replace(/\n/g, ' ');
const lastContent = lastMsg.content[lastMsg.content.length - 1]; const lastContent = lastMsg.content[lastMsg.content.length - 1];
console.log(lastContent)
if (lastContent?.type === "text") { if (lastContent?.type === "text") {
lastContent.content += text; lastContent.content += text;
} else { } else {
@ -558,7 +556,6 @@ const getWrite = (reader) => {
// 7 // 7
if (chunk.isEnd || chunk.is_end) { if (chunk.isEnd || chunk.is_end) {
lastMsg.isEnd = true; lastMsg.isEnd = true;
console.log(lastMsg)
lastMsg.time = formatDate(new Date()); lastMsg.time = formatDate(new Date());
} }

Loading…
Cancel
Save