workerd
workerd copied to clipboard
`AiTextToImageOutput` should be a ReadableStream instead of `Uint8Array`
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