transitive-bullshit / agentic

AI agent stdlib that works with any LLM and TypeScript AI SDK.
https://agentic.so
MIT License
16.22k stars 2.12k forks source link

Uncatchable Exception #554

Closed nhuethmayr closed 1 year ago

nhuethmayr commented 1 year ago

Verify latest release

Verify webapp is working

Environment details

Node 18.13

Describe the Bug

Hi, I'm using the following code to call ChatGPT

try {
const res = await this.api.sendMessage(`Please translate the following: ${content}`);
} catch(err)
{...}

the code runs fine and I hit the catch block when there are network issues for example. On other occasions, I get the stack trace below and I can't quite figure why it does not trigger the error handling.

const error = new types.ChatGPTError(msg, { cause: res })
                            ^
ChatGPTError: OpenAI error 429: {
  "error": {
    "message": "That model is currently overloaded with other requests. You can retry your request, or contact us through our help center at help.openai.com if the error persists. (Please include the request ID xxx in your message.)",
    "type": "server_error",
    "param": null,
    "code": null
  }
}

    at Promise.then.promptTokens (C:\Users\Norbe\GitHub\howmany-scraper\node_modules\chatgpt\src\chatgpt-api.ts:263:29)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {