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

AiTextToImageOutput should be a ReadableStream instead of Uint8Array #2470

Open
Kynson opened this issue Aug 1, 2024 · 0 comments
Open

AiTextToImageOutput should be a ReadableStream instead of Uint8Array #2470

Kynson opened this issue Aug 1, 2024 · 0 comments
Assignees
Labels
types Related to @cloudflare/workers-types

Comments

@Kynson
Copy link

Kynson commented Aug 1, 2024

Hello,

I am using env.AI.run('@cf/stabilityai/stable-diffusion-xl-base-1.0', input) to generate image. The return type of this function is AiTextToImageOutput which is a type alias of Uint8Array. Yet, env.AI.run() seems to return a ReadableStream instead of Uint8Array

Minimal reproducible example

const result = await env.AI.run(
    "@cf/stabilityai/stable-diffusion-xl-base-1.0",
   {
      prompt:
        "An artistic cartoon of a cat playing with a new technology gadget in a sunny computer lab, surrounded by colorful flowers and Server guarantees serene background",
      num_steps: 20,
      guidance: 7,
   }
  );
// logs:
// ReadableStream {
//  locked: false,
//  [state]: 'readable',
//  [supportsBYOB]: true,
//  [length]: undefined
// }
console.log(result);

Tested with

wrangler version: 3.67.1
@cloudflare/workers-types version: 4.20240725.0
node version: 22.5.0

I am happy to submit a PR if this a bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
types Related to @cloudflare/workers-types
Projects
Status: Other
Development

No branches or pull requests

2 participants