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

Could not resolve a few of packages in @anthropic-ai/bedrock-sdk #314

Open
Code-Hex opened this issue Mar 6, 2024 · 2 comments
Open

Could not resolve a few of packages in @anthropic-ai/bedrock-sdk #314

Code-Hex opened this issue Mar 6, 2024 · 2 comments
Assignees

Comments

@Code-Hex
Copy link

Code-Hex commented Mar 6, 2024

Environment:

  • wrangler@3.31.0
  • miniflare@3.20240223.1
  • typescript@5.3.3

Enabled compatibility_flags = [ "nodejs_compat" ] in wrangler.toml
https://developers.cloudflare.com/workers/runtime-apis/nodejs/#enable-nodejs-with-workers

✘ [ERROR] Could not resolve "assert"

    ../../node_modules/.pnpm/@anthropic-ai+bedrock-sdk@0.9.0/node_modules/@anthropic-ai/bedrock-sdk/auth.mjs:1:19:
      1 │ import assert from 'assert';
        ╵                    ~~~~~~~~

  The package "assert" wasn't found on the file system but is built into node.
  Add "node_compat = true" to your wrangler.toml file and make sure to prefix the module name with "node:" to enable Node.js compatibility.


✘ [ERROR] Could not resolve "stream"

    ../../node_modules/.pnpm/@smithy+eventstream-serde-node@2.1.3/node_modules/@smithy/eventstream-serde-node/dist-es/EventStreamMarshaller.js:2:25:
      2 │ import { Readable } from "stream";
        ╵                          ~~~~~~~~

  The package "stream" wasn't found on the file system but is built into node.
  Add "node_compat = true" to your wrangler.toml file and make sure to prefix the module name with "node:" to enable Node.js compatibility.
@Code-Hex
Copy link
Author

Code-Hex commented Mar 6, 2024

Even if you edit the contents of node_modules and modify these codes, you may encounter the following error.

✘ [ERROR] No matching export in "../../node_modules/.pnpm/@aws-sdk+credential-providers@3.525.0/node_modules/@aws-sdk/credential-providers/dist-es/index.browser.js" for import "fromNodeProviderChain"

    ../../node_modules/.pnpm/@anthropic-ai+bedrock-sdk@0.9.0/node_modules/@anthropic-ai/bedrock-sdk/auth.mjs:3:9:
      3 │ import { fromNodeProviderChain } from '@aws-sdk/credential-providers';
        ╵          ~~~~~~~~~~~~~~~~~~~~~

To resolve this, it was necessary to apply the following code:

const signer = new SignatureV4({
        service: 'bedrock',
        region: props.regionName,
        credentials: {
                accessKeyId: props.awsAccessKey ?? "",
                secretAccessKey: props.awsSecretKey ?? "",
                sessionToken: props.awsSessionToken
        },
        sha256: Sha256,
});

@rattrayalex
Copy link
Collaborator

Thanks for the report. I'm not sure we'll be able to prioritize Cloudflare Workers support for the Bedrock SDK in the near term, but we would like to resolve this if it's tractable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants