File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff 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 ( ) => {
You can’t perform that action at this time.
0 commit comments