mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 04:48:53 +00:00
feat: add upscaler & bg remover (#6967)
This commit is contained in:
@@ -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'
|
||||
);
|
||||
|
||||
@@ -77,6 +77,17 @@ export function registerCopilotProvider<
|
||||
});
|
||||
}
|
||||
|
||||
export function unregisterCopilotProvider(type: CopilotProviderType) {
|
||||
COPILOT_PROVIDER.delete(type);
|
||||
ASSERT_CONFIG.delete(type);
|
||||
for (const providers of PROVIDER_CAPABILITY_MAP.values()) {
|
||||
const index = providers.indexOf(type);
|
||||
if (index !== -1) {
|
||||
providers.splice(index, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Asserts that the config is valid for any registered providers
|
||||
export function assertProvidersConfigs(config: Config) {
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user