mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-26 23:34:47 +08:00
feat: append try catch (#280)
This commit is contained in:
@@ -40,21 +40,26 @@ export async function* chatStream(
|
|||||||
env.NEXT_PUBLIC_STATIC_WEBSITE_ONLY ||
|
env.NEXT_PUBLIC_STATIC_WEBSITE_ONLY ||
|
||||||
location.search.includes("mock") ||
|
location.search.includes("mock") ||
|
||||||
location.search.includes("replay=")
|
location.search.includes("replay=")
|
||||||
) {
|
)
|
||||||
return yield* chatReplayStream(userMessage, params, options);
|
return yield* chatReplayStream(userMessage, params, options);
|
||||||
}
|
|
||||||
const stream = fetchStream(resolveServiceURL("chat/stream"), {
|
try{
|
||||||
body: JSON.stringify({
|
const stream = fetchStream(resolveServiceURL("chat/stream"), {
|
||||||
messages: [{ role: "user", content: userMessage }],
|
body: JSON.stringify({
|
||||||
...params,
|
messages: [{ role: "user", content: userMessage }],
|
||||||
}),
|
...params,
|
||||||
signal: options.abortSignal,
|
}),
|
||||||
});
|
signal: options.abortSignal,
|
||||||
for await (const event of stream) {
|
});
|
||||||
yield {
|
|
||||||
type: event.event,
|
for await (const event of stream) {
|
||||||
data: JSON.parse(event.data),
|
yield {
|
||||||
} as ChatEvent;
|
type: event.event,
|
||||||
|
data: JSON.parse(event.data),
|
||||||
|
} as ChatEvent;
|
||||||
|
}
|
||||||
|
}catch(e){
|
||||||
|
console.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user