feat: append try catch (#280)
This commit is contained in:
parent
9d6652b1c2
commit
5ae07878d5
|
|
@ -40,21 +40,26 @@ export async function* chatStream(
|
|||
env.NEXT_PUBLIC_STATIC_WEBSITE_ONLY ||
|
||||
location.search.includes("mock") ||
|
||||
location.search.includes("replay=")
|
||||
) {
|
||||
)
|
||||
return yield* chatReplayStream(userMessage, params, options);
|
||||
}
|
||||
const stream = fetchStream(resolveServiceURL("chat/stream"), {
|
||||
body: JSON.stringify({
|
||||
messages: [{ role: "user", content: userMessage }],
|
||||
...params,
|
||||
}),
|
||||
signal: options.abortSignal,
|
||||
});
|
||||
for await (const event of stream) {
|
||||
yield {
|
||||
type: event.event,
|
||||
data: JSON.parse(event.data),
|
||||
} as ChatEvent;
|
||||
|
||||
try{
|
||||
const stream = fetchStream(resolveServiceURL("chat/stream"), {
|
||||
body: JSON.stringify({
|
||||
messages: [{ role: "user", content: userMessage }],
|
||||
...params,
|
||||
}),
|
||||
signal: options.abortSignal,
|
||||
});
|
||||
|
||||
for await (const event of stream) {
|
||||
yield {
|
||||
type: event.event,
|
||||
data: JSON.parse(event.data),
|
||||
} as ChatEvent;
|
||||
}
|
||||
}catch(e){
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue