Skip to content

Commit

Permalink
feat: handle response error
Browse files Browse the repository at this point in the history
  • Loading branch information
lucgagan committed Oct 4, 2023
1 parent 5a1f371 commit bdaf30f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/createCompletions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,18 @@ const consumeStream = async (stream: ReadableStream, onUpdate: OnUpdate) => {
};

const parseResponse = (response: any) => {
// response {
// error: {
// message: 'The model `gpt-4-32k` does not exist or you do not have access to it. Learn more: https://help.openai.com/en/articles/7102672-how-can-i-access-gpt-4.',
// type: 'invalid_request_error',
// param: null,
// code: 'model_not_found'
// }
// }
if (response.error) {
throw new UnrecoverableRemoteError(response.error.message);
}

return response.choices.map((choice: any) => {
const parsedChoice: Choice = {
role: choice.message.role,
Expand Down

0 comments on commit bdaf30f

Please sign in to comment.