@@ -36,7 +36,7 @@ import type {
3636 ZeroShotImageClassificationOutput ,
3737} from "@huggingface/tasks" ;
3838import { HF_ROUTER_URL } from "../config.js" ;
39- import { InferenceClientProviderOutputError } from "../errors.js" ;
39+ import { InferenceClientInputError , InferenceClientProviderOutputError } from "../errors.js" ;
4040import type { TabularClassificationOutput } from "../tasks/tabular/tabularClassification.js" ;
4141import type { BodyParams , RequestArgs , UrlParams } from "../types.js" ;
4242import { toArray } from "../utils/toArray.js" ;
@@ -141,10 +141,9 @@ export class HFInferenceTextToImageTask extends HFInferenceTask implements TextT
141141 if ( "data" in response && Array . isArray ( response . data ) && response . data [ 0 ] . b64_json ) {
142142 const base64Data = response . data [ 0 ] . b64_json ;
143143 if ( outputType === "url" ) {
144- console . warn (
145- "hf-inference provider does not support URL output for this model, returning base64 data URL instead"
144+ throw new InferenceClientInputError (
145+ "hf-inference provider does not support URL output for this model. Use outputType 'blob' or 'json' instead. "
146146 ) ;
147- return `data:image/jpeg;base64,${ base64Data } ` ;
148147 }
149148 const base64Response = await fetch ( `data:image/jpeg;base64,${ base64Data } ` ) ;
150149 return await base64Response . blob ( ) ;
@@ -159,12 +158,14 @@ export class HFInferenceTextToImageTask extends HFInferenceTask implements TextT
159158 }
160159 }
161160 if ( response instanceof Blob ) {
162- if ( outputType === "url" || outputType === "json" ) {
163- console . warn (
164- "hf-inference provider does not support URL output for this model, returning base64 data URL instead"
161+ if ( outputType === "url" ) {
162+ throw new InferenceClientInputError (
163+ "hf-inference provider does not support URL output for this model. Use outputType 'blob' or 'json' instead. "
165164 ) ;
165+ }
166+ if ( outputType === "json" ) {
166167 const b64 = await response . arrayBuffer ( ) . then ( ( buf ) => Buffer . from ( buf ) . toString ( "base64" ) ) ;
167- return outputType === "url" ? `data:image/jpeg;base64, ${ b64 } ` : { output : `data:image/jpeg;base64,${ b64 } ` } ;
168+ return { output : `data:image/jpeg;base64,${ b64 } ` } ;
168169 }
169170 return response ;
170171 }
0 commit comments