Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

feat: adapt new fal response (#7042)

darkskygit535254fdf6bc
diff --git a/packages/backend/server/src/plugins/copilot/providers/fal.ts b/packages/backend/server/src/plugins/copilot/providers/fal.ts
index 5f9c690036..151f2233ce 100644
--- a/packages/backend/server/src/plugins/copilot/providers/fal.ts
+++ b/packages/backend/server/src/plugins/copilot/providers/fal.ts
@@ -13,9 +13,16 @@ export type FalConfig = {
apiKey: string;
};
+export type FalImage = {
+ url: string;
+ seed: number;
+ file_name: string;
+};
+
export type FalResponse = {
detail: Array<{ msg: string }> | string;
- images: Array<{ url: string }>;
+ images?: Array<FalImage>;
+ image?: FalImage;
};
type FalPrompt = {
@@ -122,12 +129,17 @@ export class FalProvider
signal: options.signal,
}).then(res => res.json())) as FalResponse;
- if (!data.images?.length) {
+ if (!data.images?.length && !data.image?.url) {
const error = this.extractError(data);
throw new Error(
error ? `Failed to generate image: ${error}` : 'No images generated'
);
}
+
+ if (data.image?.url) {
+ return [data.image.url];
+ }
+
return data.images?.map(image => image.url) || [];
}