Spaces:
Running
Running
muxi feng
commited on
Commit
·
013ade0
1
Parent(s):
a15b47f
修复模型bug
Browse files- app/api/lemur/route.ts +1 -1
- app/api/openai/[...path]/route.ts +1 -0
- app/components/login.tsx +1 -2
- app/requests.ts +4 -4
- app/store/user.ts +2 -2
app/api/lemur/route.ts
CHANGED
@@ -105,7 +105,7 @@ async function createStream(res: Response) {
|
|
105 |
}
|
106 |
try {
|
107 |
const json = JSON.parse(data);
|
108 |
-
if (data.indexOf("content") == -1) {
|
109 |
controller.close();
|
110 |
return;
|
111 |
}
|
|
|
105 |
}
|
106 |
try {
|
107 |
const json = JSON.parse(data);
|
108 |
+
if (data.indexOf("content") == -1||data.origin=="lemur") {
|
109 |
controller.close();
|
110 |
return;
|
111 |
}
|
app/api/openai/[...path]/route.ts
CHANGED
@@ -12,6 +12,7 @@ async function createStream(res: Response) {
|
|
12 |
function onParse(event: any) {
|
13 |
if (event.type === "event") {
|
14 |
const data = event.data;
|
|
|
15 |
// https://beta.openai.com/docs/api-reference/completions/create#completions/create-stream
|
16 |
if (data === "[DONE]") {
|
17 |
controller.close();
|
|
|
12 |
function onParse(event: any) {
|
13 |
if (event.type === "event") {
|
14 |
const data = event.data;
|
15 |
+
// console.log(data)
|
16 |
// https://beta.openai.com/docs/api-reference/completions/create#completions/create-stream
|
17 |
if (data === "[DONE]") {
|
18 |
controller.close();
|
app/components/login.tsx
CHANGED
@@ -41,8 +41,7 @@ export function Login(){
|
|
41 |
}
|
42 |
|
43 |
useEffect(()=>{
|
44 |
-
|
45 |
-
setImg(userStore.img)
|
46 |
},[])
|
47 |
|
48 |
return (
|
|
|
41 |
}
|
42 |
|
43 |
useEffect(()=>{
|
44 |
+
getCode()
|
|
|
45 |
},[])
|
46 |
|
47 |
return (
|
app/requests.ts
CHANGED
@@ -300,7 +300,7 @@ export async function requestChatStream(
|
|
300 |
return
|
301 |
}
|
302 |
}
|
303 |
-
if (Bot == "OpenAI") {
|
304 |
const req = makeRequestParam(messages, {
|
305 |
stream: true,
|
306 |
overrideModel: options?.overrideModel,
|
@@ -369,7 +369,7 @@ export async function requestChatStream(
|
|
369 |
console.error("NetWork Error", err);
|
370 |
options?.onError(err as Error);
|
371 |
}
|
372 |
-
} else if (Bot == "OpenAI绘画") {
|
373 |
console.log("[Request] ", messages[messages.length - 1].content);
|
374 |
const req = makeImageRequestParam(messages);
|
375 |
const controller = new AbortController();
|
@@ -403,7 +403,7 @@ export async function requestChatStream(
|
|
403 |
console.error("NetWork Error", err);
|
404 |
options?.onMessage("请换一个问题试试吧", true);
|
405 |
}
|
406 |
-
} else if (Bot == "必应") {
|
407 |
console.log("[Request] ", messages[messages.length - 1].content);
|
408 |
const controller = new AbortController();
|
409 |
const reqTimeoutId = setTimeout(() => controller.abort(), TIME_OUT_MS);
|
@@ -438,7 +438,7 @@ export async function requestChatStream(
|
|
438 |
console.error("NetWork Error", err);
|
439 |
options?.onMessage("请换一个问题试试吧", true);
|
440 |
}
|
441 |
-
} else if (Bot == "万卷") {
|
442 |
console.log("[Request] ", messages[messages.length - 1].content);
|
443 |
const controller = new AbortController();
|
444 |
const reqTimeoutId = setTimeout(() => controller.abort(), TIME_OUT_MS);
|
|
|
300 |
return
|
301 |
}
|
302 |
}
|
303 |
+
if (Bot == "OpenAI (VIP)") {
|
304 |
const req = makeRequestParam(messages, {
|
305 |
stream: true,
|
306 |
overrideModel: options?.overrideModel,
|
|
|
369 |
console.error("NetWork Error", err);
|
370 |
options?.onError(err as Error);
|
371 |
}
|
372 |
+
} else if (Bot == "OpenAI绘画 (VIP)") {
|
373 |
console.log("[Request] ", messages[messages.length - 1].content);
|
374 |
const req = makeImageRequestParam(messages);
|
375 |
const controller = new AbortController();
|
|
|
403 |
console.error("NetWork Error", err);
|
404 |
options?.onMessage("请换一个问题试试吧", true);
|
405 |
}
|
406 |
+
} else if (Bot == "必应 (VIP)") {
|
407 |
console.log("[Request] ", messages[messages.length - 1].content);
|
408 |
const controller = new AbortController();
|
409 |
const reqTimeoutId = setTimeout(() => controller.abort(), TIME_OUT_MS);
|
|
|
438 |
console.error("NetWork Error", err);
|
439 |
options?.onMessage("请换一个问题试试吧", true);
|
440 |
}
|
441 |
+
} else if (Bot == "万卷 (VIP)") {
|
442 |
console.log("[Request] ", messages[messages.length - 1].content);
|
443 |
const controller = new AbortController();
|
444 |
const reqTimeoutId = setTimeout(() => controller.abort(), TIME_OUT_MS);
|
app/store/user.ts
CHANGED
@@ -131,7 +131,7 @@ export const useUserStore = create<UserStore>()(
|
|
131 |
set(() => ({ user: user }));
|
132 |
},
|
133 |
setUuidAndImg(uuid: string,img:string) {
|
134 |
-
set(() => ({ uuid:
|
135 |
},
|
136 |
async getCode() {
|
137 |
let res = await fetch(
|
@@ -283,7 +283,7 @@ export const useUserStore = create<UserStore>()(
|
|
283 |
);
|
284 |
} else {
|
285 |
showToast(responsedata.msg);
|
286 |
-
if(
|
287 |
getLogin()
|
288 |
}
|
289 |
}
|
|
|
131 |
set(() => ({ user: user }));
|
132 |
},
|
133 |
setUuidAndImg(uuid: string,img:string) {
|
134 |
+
set(() => ({ uuid:uuid, img:img}));
|
135 |
},
|
136 |
async getCode() {
|
137 |
let res = await fetch(
|
|
|
283 |
);
|
284 |
} else {
|
285 |
showToast(responsedata.msg);
|
286 |
+
if(responsedata.msg=="未登录!"){
|
287 |
getLogin()
|
288 |
}
|
289 |
}
|