session message should exclude all error tips

This commit is contained in:
cyhhao
2023-04-03 14:13:57 +08:00
parent 5843303076
commit 73f4ea38c6
3 changed files with 19 additions and 9 deletions

View File

@@ -114,7 +114,7 @@ export async function requestChatStream(
filterBot?: boolean;
modelConfig?: ModelConfig;
onMessage: (message: string, done: boolean) => void;
onError: (error: Error) => void;
onError: (error: Error, statusCode?: number) => void;
onController?: (controller: AbortController) => void;
},
) {
@@ -178,11 +178,10 @@ export async function requestChatStream(
finish();
} else if (res.status === 401) {
console.error("Anauthorized");
responseText = Locale.Error.Unauthorized;
finish();
options?.onError(new Error("Anauthorized"), res.status);
} else {
console.error("Stream Error", res.body);
options?.onError(new Error("Stream Error"));
options?.onError(new Error("Stream Error"), res.status);
}
} catch (err) {
console.error("NetWork Error", err);