feat: AI对话修改接口
This commit is contained in:
2
src/api/upload.ts
Normal file
2
src/api/upload.ts
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
@@ -178,16 +178,28 @@
|
|||||||
if (!event.trim()) continue
|
if (!event.trim()) continue
|
||||||
|
|
||||||
// 过滤掉 id: 等字段,只取 data:
|
// 过滤掉 id: 等字段,只取 data:
|
||||||
const dataLines = event
|
|
||||||
.split(/\n/)
|
|
||||||
.filter((line) => line.startsWith('data:'))
|
|
||||||
.map((line) => line.replace(/^data:\s*/, '').trim())
|
|
||||||
|
|
||||||
|
let isNodeIdEvent = false
|
||||||
|
if(event.startsWith('event:')){
|
||||||
|
isNodeIdEvent = true
|
||||||
|
// continue
|
||||||
|
}
|
||||||
|
|
||||||
|
const dataLines = event
|
||||||
|
.split(/\n/)
|
||||||
|
.filter((line) => line.startsWith('data:'))
|
||||||
|
.map((line) => line.replace(/^data:\s*/, '').trim())
|
||||||
|
console.log('dataLInes',dataLines);
|
||||||
|
if(isNodeIdEvent){
|
||||||
|
params.versionID = dataLines[0]
|
||||||
|
}
|
||||||
|
|
||||||
if (dataLines.length === 0) continue
|
if (dataLines.length === 0) continue
|
||||||
const jsonText = dataLines.join('\n')
|
const jsonText = dataLines.join('\n')
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const jsonData = JSON.parse(jsonText)
|
const jsonData = JSON.parse(jsonText)
|
||||||
|
|
||||||
// 赋值 project_id 和 version_id
|
// 赋值 project_id 和 version_id
|
||||||
if (jsonData.project_id) params.projectID = jsonData.project_id
|
if (jsonData.project_id) params.projectID = jsonData.project_id
|
||||||
if (jsonData.version_id) params.versionID = jsonData.version_id
|
if (jsonData.version_id) params.versionID = jsonData.version_id
|
||||||
|
|||||||
@@ -77,7 +77,7 @@
|
|||||||
// return self.renderToken(tokens, idx, options, env, self)
|
// return self.renderToken(tokens, idx, options, env, self)
|
||||||
// }
|
// }
|
||||||
const str = md.render(props.content.text)
|
const str = md.render(props.content.text)
|
||||||
console.log('str',str)
|
// console.log('str',str)
|
||||||
return str
|
return str
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user