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
Update Anthropic SDK to 0.5.X to support Claude V2 #1932
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
} catch (e: any) { | ||
// Anthropic doesn't actually throw JavaScript error objects at the moment. | ||
// We convert the error so the async caller can recognize it correctly. | ||
if (e?.name === "AbortError") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do they still not throw JS errors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do; AbortError's in JavaScript weirdly don't have their own class:
Note: When abort() is called, the fetch() promise rejects with an Error of type DOMException, with name AbortError.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh wow that explains a lot. Thanks.
Thanks for this! It seems like this doesn't pass our integration test:
Fails the batch request abort test as expected (unfortunately) but also the basic streaming one. CC @dqbd but I can just have a look as well. |
Fixed things up and added back in abort for both (taking some ideas from #1912!) Unfortunately, it seems they're doing some things that break edge environments and it's failing our build tests. Will contact them and try to get them to fix it. |
|
||
if (options.signal?.aborted) { | ||
stream.controller.abort(); | ||
throw new Error("AbortError: User aborted the request."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, you might want this to be more like:
const err = new Error("User aborted the request.")
err.name = "AbortError";
throw err;
which I believe to be closer to what JS runtimes do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gets caught by our caller class which would catch this - we could/should change it in the future but it's out of scope for this one.
Ok, so it's actually intentional and the newest version of Bumped the version and it builds locally so it should pass our CI. |
Thanks again @cwoolum! Will be in tonights release 🙂 |
Awesome, thanks! Forgot to include my twitter handle if it still matters. @chriswoolum |
Anthropic has released Claude V2 which makes use of an updated API. The TypeScript SDK 0.5.X has been rewritten to support the new API schema which also applies to Claude V1.
It should be noted that the TypeScript SDK no longer supports
AbortController
inherently and so it can only be used for streaming responses to short circuit what is returned by the LangchainJS client.Fixes # (issue)