feat: add upscaler & bg remover (#6967)

This commit is contained in:
darkskygit
2024-05-16 11:09:33 +00:00
parent f37bbb0784
commit a3f3d09764
7 changed files with 105 additions and 6 deletions

View File

@@ -14,7 +14,7 @@ export type FalConfig = {
};
export type FalResponse = {
detail: Array<{ msg: string }>;
detail: Array<{ msg: string }> | string;
images: Array<{ url: string }>;
};
@@ -32,6 +32,8 @@ export class FalProvider
'fast-turbo-diffusion',
// image to image
'lcm-sd15-i2i',
'clarity-upscaler',
'imageutils/rembg',
];
constructor(private readonly config: FalConfig) {
@@ -87,7 +89,11 @@ export class FalProvider
}).then(res => res.json())) as FalResponse;
if (!data.images?.length) {
const error = data.detail?.[0]?.msg;
const error = Array.isArray(data.detail)
? data.detail[0]?.msg
: typeof data.detail === 'string'
? data.detail
: '';
throw new Error(
error ? `Invalid message: ${error}` : 'No images generated'
);