@@ -14,6 +14,9 @@ interface Base64ImageGeneration {
14
14
interface OutputUrlImageGeneration {
15
15
output : string [ ] ;
16
16
}
17
+ interface HyperbolicTextToImageOutput {
18
+ images : Array < { image : string } >
19
+ }
17
20
18
21
function getResponseFormatArg ( provider : InferenceProvider ) {
19
22
switch ( provider ) {
@@ -39,12 +42,12 @@ export async function textToImage(args: TextToImageArgs, options?: Options): Pro
39
42
! args . provider || args . provider === "hf-inference" || args . provider === "sambanova"
40
43
? args
41
44
: {
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 , {
48
51
...options ,
49
52
taskHint : "text-to-image" ,
50
53
} ) ;
@@ -54,7 +57,7 @@ export async function textToImage(args: TextToImageArgs, options?: Options): Pro
54
57
const image = await fetch ( res . images [ 0 ] . url ) ;
55
58
return await image . blob ( ) ;
56
59
}
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" ) {
58
61
const base64Response = await fetch ( `data:image/jpeg;base64,${ res . images [ 0 ] . image } ` ) ;
59
62
const blob = await base64Response . blob ( ) ;
60
63
return blob ;
0 commit comments