Skip to content

Commit e0709b7

Browse files
committed
use @cf/black-forest-labs/flux-1-schnell
1 parent 39bcb5a commit e0709b7

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

packages/worker/src/worker.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,17 +162,22 @@ export default {
162162
case 'message': {
163163
await bot.sendTyping();
164164
const prompt = bot.update.message?.text?.toString() ?? '';
165-
let photo: AiTextToImageOutput;
165+
let photo: { image: string };
166166
try {
167-
photo = await env.AI.run('@cf/stabilityai/stable-diffusion-xl-base-1.0', { prompt });
167+
// @ts-expect-error broken bindings
168+
photo = await env.AI.run('@cf/black-forest-labs/flux-1-schnell', { prompt, steps: 8 });
168169
} catch (e) {
169170
console.log(e);
170171
await bot.reply(`Error: ${e as string}`);
171172
return new Response('ok');
172173
}
173-
const photo_file = new File([await new Response(photo).blob()], 'photo');
174+
const binaryString = atob(photo.image);
175+
// @ts-expect-error broken bindings
176+
const img = Uint8Array.from(binaryString, (m) => m.codePointAt(0));
177+
const photo_file = new File([await new Response(img).blob()], 'photo');
174178
const id = crypto.randomUUID();
175179
await env.R2.put(id, photo_file);
180+
console.log(`https://r2.seanbehan.ca/${id}`);
176181
await bot.replyPhoto(`https://r2.seanbehan.ca/${id}`);
177182
ctx.waitUntil(
178183
wrapPromise(async () => {

0 commit comments

Comments
 (0)