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

Abort Signal not forwarded with Bedrock #3094

Open
IdoPesok opened this issue Sep 22, 2024 · 0 comments
Open

Abort Signal not forwarded with Bedrock #3094

IdoPesok opened this issue Sep 22, 2024 · 0 comments
Labels
ai/provider enhancement New feature or request

Comments

@IdoPesok
Copy link
Contributor

Description

AI sdk is not using the bedrock library underneath, not fetch, so the abort signal is not forwarded

Code example

import { streamText } from "ai";
import { anthropic } from "@ai-sdk/anthropic";
import { bedrock } from "@ai-sdk/amazon-bedrock";

const main = async () => {
  const abortController = new AbortController();
  const signal = abortController.signal;

  setTimeout(() => {
    abortController.abort();
  }, 2000);

  try {
    const { textStream } = await streamText({
      // model: anthropic("claude-3-5-sonnet-20240620"),
      model: bedrock("anthropic.claude-3-5-sonnet-20240620-v1:0"),
      messages: [
        {
          role: "user",
          content: "write a long poem",
        },
      ],
      abortSignal: signal,
    });

    for await (const message of textStream) {
      console.log(message);
    }
  } catch (e) {
    console.log("got error", e);
  }
};

main();

Additional context

No response

@lgrammel lgrammel added enhancement New feature or request ai/provider labels Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ai/provider enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants