mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-24 22:09:08 +08:00
fix(server): generate image (#11599)
This commit is contained in:
@@ -476,6 +476,19 @@ const actions = [
|
|||||||
},
|
},
|
||||||
type: 'image' as const,
|
type: 'image' as const,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
promptName: ['debug:action:dalle3'],
|
||||||
|
messages: [
|
||||||
|
{
|
||||||
|
role: 'user' as const,
|
||||||
|
content: 'Panda',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
verifier: (t: ExecutionContext<Tester>, link: string) => {
|
||||||
|
t.truthy(checkUrl(link), 'should be a valid url');
|
||||||
|
},
|
||||||
|
type: 'image' as const,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const { name, promptName, messages, verifier, type } of actions) {
|
for (const { name, promptName, messages, verifier, type } of actions) {
|
||||||
|
|||||||
@@ -313,9 +313,9 @@ export class OpenAIProvider
|
|||||||
prompt,
|
prompt,
|
||||||
});
|
});
|
||||||
|
|
||||||
return result.images
|
return result.images.map(
|
||||||
.map(image => image.base64)
|
image => `data:image/png;base64,${image.base64}`
|
||||||
.filter((v): v is string => !!v);
|
);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
metrics.ai.counter('generate_images_errors').add(1, { model });
|
metrics.ai.counter('generate_images_errors').add(1, { model });
|
||||||
throw this.handleError(e, model, options);
|
throw this.handleError(e, model, options);
|
||||||
|
|||||||
Reference in New Issue
Block a user