Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Anthropic overloaded errors during streaming #193

Open
doomspork opened this issue Nov 21, 2024 · 6 comments · Fixed by #194
Open

Handle Anthropic overloaded errors during streaming #193

doomspork opened this issue Nov 21, 2024 · 6 comments · Fixed by #194
Assignees
Labels
bug Something isn't working

Comments

@doomspork
Copy link

doomspork commented Nov 21, 2024

As we're making more use of streaming we're seeing more of these errors recently:

[error] Unsupported event received when parsing Anthropic response: "event: error\ndata: {\"type\":\"error\",\"error\":{\"details\":null,\"type\":\"overloaded_error\",\"message\":\"Overloaded\"}        }"

The result is this error logged but the code seems to proceed like everything is okay. I would expect/prefer an error were raised so we could retry the conversation versus leaving it in a partial and incomplete state.

I started spelunking today but it looks like handling this could be a decent sized changes so I thought it was best to bring it here for discussion.

Anthropic documentation around streaming errors for reference: https://docs.anthropic.com/en/api/messages-streaming#error-events

@brainlid
Copy link
Owner

Just saw this myself this morning! Thanks for reporting it.

@brainlid
Copy link
Owner

There's more to handling this than I've done so far. It helps that they keep making it reproducible. 🤦‍♂️

@brainlid brainlid reopened this Nov 22, 2024
@doomspork
Copy link
Author

I haven't had a chance to pull your changes and do my own testing but I will here shortly.

It's unfortunate how frequently their API is overloaded recently.

@brainlid
Copy link
Owner

brainlid commented Nov 22, 2024 via email

brainlid added a commit that referenced this issue Nov 23, 2024
- related to issue #193
@brainlid
Copy link
Owner

@doomspork I pushed up a hopefully more complete fix.

When it happens again, the LLMChain.run(chain, ...) result will be: {:error, updated_chain, %LangChain.LangChainError{} = error}.

Where the error has a type of "overloaded_error" (that's what they return).

If the pattern holds, it will be down again tomorrow morning (but it's the weekend, so perhaps not). I'll be watching for it too though.

@doomspork
Copy link
Author

Sounds good @brainlid! Thanks for tackling this one 🙏 I'll let you know what I see 🫡

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants