|
@@ -64,25 +64,29 @@ export function getChatResponse({
|
|
|
|
|
|
// 处理错误事件
|
|
|
eventSource.onerror = (e) => {
|
|
|
- error = e
|
|
|
+ error = e;
|
|
|
resolveQueuePromise();
|
|
|
eventSource.close(); // 关闭连接
|
|
|
};
|
|
|
|
|
|
- ctrl.signal.addEventListener("abort", () => {
|
|
|
+ ctrl.signal.addEventListener("abort", (e) => {
|
|
|
+ // FIXME
|
|
|
+ // if (e?.target?.reason?.message) {
|
|
|
+ // error = e.target.reason
|
|
|
+ // } else {
|
|
|
+ // done = true
|
|
|
+ // }
|
|
|
+ done = true;
|
|
|
resolveQueuePromise();
|
|
|
eventSource.close();
|
|
|
});
|
|
|
- fetch(
|
|
|
- `${process.env.NEXT_PUBLIC_GPT_BASE_URL}/ai_agent_park_chat_new`,
|
|
|
- {
|
|
|
- method: "POST",
|
|
|
- body: JSON.stringify({ ...data, uid }),
|
|
|
- headers: {
|
|
|
- "Content-Type": "application/json",
|
|
|
- },
|
|
|
- }
|
|
|
- );
|
|
|
+ fetch(`${process.env.NEXT_PUBLIC_GPT_BASE_URL}/ai_agent_park_chat_new`, {
|
|
|
+ method: "POST",
|
|
|
+ body: JSON.stringify({ ...data, uid }),
|
|
|
+ headers: {
|
|
|
+ "Content-Type": "application/json",
|
|
|
+ },
|
|
|
+ });
|
|
|
|
|
|
while (!done || queue.length > 0) {
|
|
|
clearTimeout(timer);
|