langchainjs
langchainjs copied to clipboard
cloudflare[minor]: use native Cloudflare Workers AI binding
As of 2024-04-11, there's no need to use the @cloudflare/ai package and it's deprecated:
https://developers.cloudflare.com/workers-ai/changelog/
This swaps the code over to use the native binding directly, and updates @cloudflare/workers-types which now ships the Ai type. No other code changes are needed.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| langchainjs-docs | ✅ Ready (Inspect) | Visit Preview | Sep 11, 2024 0:01am |
1 Skipped Deployment
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| langchainjs-api-refs | ⬜️ Ignored (Inspect) | Sep 11, 2024 0:01am |
Hey so just got wind that the Rest API methods will be available in the main SDK:
https://www.npmjs.com/package/cloudflare
We should wait to land this until that is generally ready
The general cloudflare SDK makes sense outside of Workers, but bindings inside of Workers are faster and more secure - no additional authentication required, so using it inside a Worker for anything that has native bindings doesn't make a lot of sense in my experience.
Updating https://github.com/Cherry/langchainjs/blob/4b9192176440b4acab9eac60a140200640d8bee2/libs/langchain-cloudflare/src/chat_models.ts#L78 to use the official SDK once the AI endpoints are available there makes sense, but https://github.com/Cherry/langchainjs/blob/fix/workers-ai-native-binding/libs/langchain-cloudflare/src/embeddings.ts seems to be intended for use only within a Worker.
Yeah for sure but ideally we don't lose functionality for people using it outside workers - I've done that myself in demos.
It should accept either a binding or a config object/client IMO.
Agreed that would be ideal, but it doesn't look like it does today: https://github.com/langchain-ai/langchainjs/blob/main/libs/langchain-cloudflare/src/embeddings.ts.
No functionality here will be lost, so perhaps that improvement would be better served in another PR?
As far as I can tell, this is ready to merge. Is there anything left to resolve before merging?
Apologies will have a look as soon as I can!
Hey team, I have an issue that might be related to this!
I'm looking forward to this PR!
@Cherry is attempting to deploy a commit to the LangChain Team on Vercel.
A member of the Team first needs to authorize it.
Hey, extremely sorry about the delay, this looks good!
We are about to push minor versions of all packages related to the 0.3 release, will push this out alongside that.