@@ -14,6 +14,9 @@ interface Base64ImageGeneration {
1414interface OutputUrlImageGeneration {
1515 output : string [ ] ;
1616}
17+ interface HyperbolicTextToImageOutput {
18+ images : Array < { image : string } >
19+ }
1720
1821function getResponseFormatArg ( provider : InferenceProvider ) {
1922 switch ( provider ) {
@@ -39,12 +42,12 @@ export async function textToImage(args: TextToImageArgs, options?: Options): Pro
3942 ! args . provider || args . provider === "hf-inference" || args . provider === "sambanova"
4043 ? args
4144 : {
42- ...omit ( args , [ "inputs" , "parameters" ] ) ,
43- ...args . parameters ,
44- ...getResponseFormatArg ( args . provider ) ,
45- prompt : args . inputs ,
46- } ;
47- const res = await request < TextToImageOutput | Base64ImageGeneration | OutputUrlImageGeneration > ( payload , {
45+ ...omit ( args , [ "inputs" , "parameters" ] ) ,
46+ ...args . parameters ,
47+ ...getResponseFormatArg ( args . provider ) ,
48+ prompt : args . inputs ,
49+ } ;
50+ const res = await request < TextToImageOutput | Base64ImageGeneration | OutputUrlImageGeneration | HyperbolicTextToImageOutput > ( payload , {
4851 ...options ,
4952 taskHint : "text-to-image" ,
5053 } ) ;
@@ -54,7 +57,7 @@ export async function textToImage(args: TextToImageArgs, options?: Options): Pro
5457 const image = await fetch ( res . images [ 0 ] . url ) ;
5558 return await image . blob ( ) ;
5659 }
57- if ( args . provider === "hyperbolic" && "images" in res && Array . isArray ( res . images ) && res . images [ 0 ] . image ) {
60+ if ( args . provider === "hyperbolic" && "images" in res && Array . isArray ( res . images ) && res . images [ 0 ] && typeof res . images [ 0 ] . image === "string" ) {
5861 const base64Response = await fetch ( `data:image/jpeg;base64,${ res . images [ 0 ] . image } ` ) ;
5962 const blob = await base64Response . blob ( ) ;
6063 return blob ;
0 commit comments