mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-06-06 21:00:21 +09:00
Merge branch 'main' of https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web
This commit is contained in:
commit
4ce64ccbe1
@ -192,7 +192,10 @@ export class GeminiProApi implements LLMApi {
|
||||
requestPayload,
|
||||
getHeaders(),
|
||||
// @ts-ignore
|
||||
[{ functionDeclarations: tools.map((tool) => tool.function) }],
|
||||
tools.length > 0
|
||||
? // @ts-ignore
|
||||
[{ functionDeclarations: tools.map((tool) => tool.function) }]
|
||||
: [],
|
||||
funcs,
|
||||
controller,
|
||||
// parseSSE
|
||||
|
@ -100,7 +100,8 @@ export function fetch(url: string, options?: RequestInit): Promise<any> {
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error("stream error", e);
|
||||
throw e;
|
||||
// throw e;
|
||||
return new Response("", { status: 599 });
|
||||
});
|
||||
}
|
||||
return window.fetch(url, options);
|
||||
|
@ -119,11 +119,22 @@ pub async fn stream_fetch(
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
println!("Error response: {:?}", err.source().expect("REASON").to_string());
|
||||
let error: String = err.source()
|
||||
.map(|e| e.to_string())
|
||||
.unwrap_or_else(|| "Unknown error occurred".to_string());
|
||||
println!("Error response: {:?}", error);
|
||||
tauri::async_runtime::spawn( async move {
|
||||
if let Err(e) = window.emit(event_name, ChunkPayload{ request_id, chunk: error.into() }) {
|
||||
println!("Failed to emit chunk payload: {:?}", e);
|
||||
}
|
||||
if let Err(e) = window.emit(event_name, EndPayload{ request_id, status: 0 }) {
|
||||
println!("Failed to emit end payload: {:?}", e);
|
||||
}
|
||||
});
|
||||
StreamResponse {
|
||||
request_id,
|
||||
status: 599,
|
||||
status_text: err.source().expect("REASON").to_string(),
|
||||
status_text: "Error".to_string(),
|
||||
headers: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user