diff options
author | bobzel <zzzman@gmail.com> | 2025-01-17 11:17:15 -0500 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2025-01-17 11:17:15 -0500 |
commit | 156a2040cc51397c3656615f9133279dac900c82 (patch) | |
tree | 81fb2cf9c2c8c04cbe4b89a40d8e171103c5079c /src/server/ApiManagers/FireflyManager.ts | |
parent | fdc8741187489963353938072f05051b8986c400 (diff) |
changed to generating 4 images for each firefly request.
Diffstat (limited to 'src/server/ApiManagers/FireflyManager.ts')
-rw-r--r-- | src/server/ApiManagers/FireflyManager.ts | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/server/ApiManagers/FireflyManager.ts b/src/server/ApiManagers/FireflyManager.ts index f49cf4132..160a94d40 100644 --- a/src/server/ApiManagers/FireflyManager.ts +++ b/src/server/ApiManagers/FireflyManager.ts @@ -36,8 +36,9 @@ export default class FireflyManager extends ApiManager { ], body: JSON.stringify({ prompt, - // detailLevel: 'preview', - // modelVersion: 'image3_fast', + numVariations: 4, + detailLevel: 'preview', + modelVersion: 'image3_fast', size: { width, height }, structure: !structureUrl ? undefined @@ -61,7 +62,7 @@ export default class FireflyManager extends ApiManager { .then(response2 => response2.json().then(json => { if (json.outputs?.length) - return JSON.stringify((json.outputs?.[0] as { image: { url: string } } ?? {})?.image); + return (json.outputs as {image: {url:string }}[]).map(output => output.image); throw new Error(JSON.stringify(json)); }) ) @@ -306,13 +307,14 @@ export default class FireflyManager extends ApiManager { }) .then(uploads => this.generateImageFromStructure(req.body.prompt, req.body.width, req.body.height, uploads.structureUrl, req.body.strength, req.body.presets, uploads.styleUrl) - .then(fire => - DashUploadUtils.UploadImage(JSON.parse(fire ?? '').url).then(info => { - if (info instanceof Error) _invalid(res, info.message); - else _success(res, info); - resolver(); - }) - ) + .then(images => { + Promise.all((images ?? [new Error('no images were generated')]).map(fire => (fire instanceof Error ? fire : DashUploadUtils.UploadImage(fire.url)))) + .then(dashImages => { + if (dashImages.every(img => img instanceof Error)) _invalid(res, dashImages[0]!.message); + else _success(res, JSON.stringify(dashImages.filter(img => !(img instanceof Error)))); + }) + .then(resolver); + }) .catch(e => { _invalid(res, e.message); resolver(); |