Skip to content

Commit

Permalink
chore: raise error when fail to chat with LLM
Browse files Browse the repository at this point in the history
  • Loading branch information
CNSeniorious000 committed Aug 23, 2024
1 parent 1dc1e6b commit cc1d5b0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lib/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@ import { responseToAsyncIterator } from "./utils/iter";

export default async function* (options: ChatCompletionCreateParams) {
const res = await fetch("/api/chat", { method: "POST", body: JSON.stringify(options), headers: { "content-type": "application/json" } });
if (res.status !== 200) {
console.error(await res.text());
throw new Error(`Failed to fetch: ${res.status} ${res.statusText}`);
}
yield * responseToAsyncIterator(res);
}

0 comments on commit cc1d5b0

Please sign in to comment.