@@ -154,13 +154,16 @@ export class FalAITextToVideoTask extends FalAITask implements TextToVideoTaskHe
154154 }
155155 const requestId = response . request_id ;
156156 if ( ! requestId ) {
157- throw new HfInferenceProviderOutputError ( "Received malformed response from Fal.ai text-to-video API: no request ID found in the response" ) ;
157+ throw new HfInferenceProviderOutputError (
158+ "Received malformed response from Fal.ai text-to-video API: no request ID found in the response"
159+ ) ;
158160 }
159161 let status = response . status ;
160162
161163 const parsedUrl = new URL ( url ) ;
162- const baseUrl = `${ parsedUrl . protocol } //${ parsedUrl . host } ${ parsedUrl . host === "router.huggingface.co" ? "/fal-ai" : ""
163- } `;
164+ const baseUrl = `${ parsedUrl . protocol } //${ parsedUrl . host } ${
165+ parsedUrl . host === "router.huggingface.co" ? "/fal-ai" : ""
166+ } `;
164167
165168 // extracting the provider model id for status and result urls
166169 // from the response as it might be different from the mapped model in `url`
@@ -175,15 +178,22 @@ export class FalAITextToVideoTask extends FalAITask implements TextToVideoTaskHe
175178 const statusResponse = await fetch ( statusUrl , { headers } ) ;
176179
177180 if ( ! statusResponse . ok ) {
178- throw new HfInferenceProviderApiError ( "Failed to fetch response status from fal-ai API" ,
181+ throw new HfInferenceProviderApiError (
182+ "Failed to fetch response status from fal-ai API" ,
179183 { url : statusUrl , method : "GET" } ,
180- { requestId : statusResponse . headers . get ( "x-request-id" ) ?? "" , status : statusResponse . status , body : await statusResponse . text ( ) }
184+ {
185+ requestId : statusResponse . headers . get ( "x-request-id" ) ?? "" ,
186+ status : statusResponse . status ,
187+ body : await statusResponse . text ( ) ,
188+ }
181189 ) ;
182190 }
183191 try {
184192 status = ( await statusResponse . json ( ) ) . status ;
185193 } catch ( error ) {
186- throw new HfInferenceProviderOutputError ( "Failed to parse status response from fal-ai API: received malformed response" ) ;
194+ throw new HfInferenceProviderOutputError (
195+ "Failed to parse status response from fal-ai API: received malformed response"
196+ ) ;
187197 }
188198 }
189199
@@ -192,7 +202,9 @@ export class FalAITextToVideoTask extends FalAITask implements TextToVideoTaskHe
192202 try {
193203 result = await resultResponse . json ( ) ;
194204 } catch ( error ) {
195- throw new HfInferenceProviderOutputError ( "Failed to parse result response from fal-ai API: received malformed response" ) ;
205+ throw new HfInferenceProviderOutputError (
206+ "Failed to parse result response from fal-ai API: received malformed response"
207+ ) ;
196208 }
197209 if (
198210 typeof result === "object" &&
@@ -208,7 +220,9 @@ export class FalAITextToVideoTask extends FalAITask implements TextToVideoTaskHe
208220 return await urlResponse . blob ( ) ;
209221 } else {
210222 throw new HfInferenceProviderOutputError (
211- `Received malformed response from Fal.ai text-to-video API: expected { video: { url: string } } result format, got instead: ${ JSON . stringify ( result ) } `
223+ `Received malformed response from Fal.ai text-to-video API: expected { video: { url: string } } result format, got instead: ${ JSON . stringify (
224+ result
225+ ) } `
212226 ) ;
213227 }
214228 }
@@ -224,7 +238,9 @@ export class FalAIAutomaticSpeechRecognitionTask extends FalAITask implements Au
224238 const res = response as FalAIAutomaticSpeechRecognitionOutput ;
225239 if ( typeof res ?. text !== "string" ) {
226240 throw new HfInferenceProviderOutputError (
227- `Received malformed response from Fal.ai Automatic Speech Recognition API: expected { text: string } format, got instead: ${ JSON . stringify ( response ) } `
241+ `Received malformed response from Fal.ai Automatic Speech Recognition API: expected { text: string } format, got instead: ${ JSON . stringify (
242+ response
243+ ) } `
228244 ) ;
229245 }
230246 return { text : res . text } ;
@@ -266,22 +282,34 @@ export class FalAITextToSpeechTask extends FalAITask {
266282 const res = response as FalAITextToSpeechOutput ;
267283 if ( typeof res ?. audio ?. url !== "string" ) {
268284 throw new HfInferenceProviderOutputError (
269- `Received malformed response from Fal.ai Text-to-Speech API: expected { audio: { url: string } } format, got instead: ${ JSON . stringify ( response ) } `
285+ `Received malformed response from Fal.ai Text-to-Speech API: expected { audio: { url: string } } format, got instead: ${ JSON . stringify (
286+ response
287+ ) } `
270288 ) ;
271289 }
272290 const urlResponse = await fetch ( res . audio . url ) ;
273291 if ( ! urlResponse . ok ) {
274- throw new HfInferenceProviderApiError ( `Failed to fetch audio from ${ res . audio . url } : ${ urlResponse . statusText } ` ,
292+ throw new HfInferenceProviderApiError (
293+ `Failed to fetch audio from ${ res . audio . url } : ${ urlResponse . statusText } ` ,
275294 { url : res . audio . url , method : "GET" , headers : { "Content-Type" : "application/json" } } ,
276- { requestId : urlResponse . headers . get ( "x-request-id" ) ?? "" , status : urlResponse . status , body : await urlResponse . text ( ) }
295+ {
296+ requestId : urlResponse . headers . get ( "x-request-id" ) ?? "" ,
297+ status : urlResponse . status ,
298+ body : await urlResponse . text ( ) ,
299+ }
277300 ) ;
278301 }
279302 try {
280303 return await urlResponse . blob ( ) ;
281304 } catch ( error ) {
282- throw new HfInferenceProviderApiError ( `Failed to fetch audio from ${ res . audio . url } : ${ error instanceof Error ? error . message : String ( error ) } ` ,
305+ throw new HfInferenceProviderApiError (
306+ `Failed to fetch audio from ${ res . audio . url } : ${ error instanceof Error ? error . message : String ( error ) } ` ,
283307 { url : res . audio . url , method : "GET" , headers : { "Content-Type" : "application/json" } } ,
284- { requestId : urlResponse . headers . get ( "x-request-id" ) ?? "" , status : urlResponse . status , body : await urlResponse . text ( ) }
308+ {
309+ requestId : urlResponse . headers . get ( "x-request-id" ) ?? "" ,
310+ status : urlResponse . status ,
311+ body : await urlResponse . text ( ) ,
312+ }
285313 ) ;
286314 }
287315 }
0 commit comments