提交 f0a6820a 编写于 作者: D DebugIsFalse

fix: 处理open事件

上级 e915b9b5
......@@ -244,12 +244,17 @@ const handleStopGenerate = () => {
})
}
const handleError = (event) => {
console.log('event:', event)
askingData.value = {}
handleStopGenerate()
if (event) {
throw event
}
}
const handleOpen = (status) => {
if ([401, 403].includes(status)) {
askingData.value = {}
}
}
const fetchLinkedQuestion = async (query) => {
const { gitPath, id } = state
const messages = []
......@@ -279,6 +284,7 @@ const generateFetchData = (query) => {
}
fetchEventSource('/v1/chat/completions', {
params ,
onopen: handleOpen,
onmessage: handleMessage,
onerror: handleError,
controller: aiChatController
......
import { fetchEventSource } from '@microsoft/fetch-event-source'
const BASE_URL = 'https://gpu-pod656e861afe3d944d6b3ce77e-7862.node.inscode.run'
export default (url, { onmessage, onerror, controller, params }) => {
export default (url, { onmessage, onerror, controller, params, onopen }) => {
const token = useCookie('token')
fetchEventSource(`${BASE_URL}${url}`, {
method: 'POST',
......@@ -13,6 +13,7 @@ export default (url, { onmessage, onerror, controller, params }) => {
onopen (response) {
const status = response.status
useRequestError(status)
onopen(status)
},
onmessage (info) {
onmessage(info)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册