aboutsummaryrefslogtreecommitdiff
path: root/src/server/ApiManagers/FireflyManager.ts
diff options
context:
space:
mode:
authoreleanor-park <eleanor_park@brown.edu>2025-01-02 22:39:25 -0500
committereleanor-park <eleanor_park@brown.edu>2025-01-02 22:39:25 -0500
commit6e7cb570f9bad527cd4772bb5c715dd588fb77df (patch)
treefe1b697f6174ae4045184d9b981705757532d315 /src/server/ApiManagers/FireflyManager.ts
parent383b0487d5268bd860e514feddf09f4f3eb2fe3f (diff)
tags can now be used as style presets
Diffstat (limited to 'src/server/ApiManagers/FireflyManager.ts')
-rw-r--r--src/server/ApiManagers/FireflyManager.ts7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/server/ApiManagers/FireflyManager.ts b/src/server/ApiManagers/FireflyManager.ts
index 4c4aac5e0..cb5d7c1da 100644
--- a/src/server/ApiManagers/FireflyManager.ts
+++ b/src/server/ApiManagers/FireflyManager.ts
@@ -20,9 +20,10 @@ export default class FireflyManager extends ApiManager {
return undefined;
});
- generateImageFromStructure = (prompt: string = 'a realistic illustration of a cat coding', width: number = 2048, height: number = 2048, structureUrl: string, strength: number = 50) =>
+ generateImageFromStructure = (prompt: string = 'a realistic illustration of a cat coding', width: number = 2048, height: number = 2048, structureUrl: string, strength: number = 50, styles: string[]) =>
this.getBearerToken().then(response =>
response?.json().then((data: { access_token: string }) =>
+ //prettier-ignore
fetch('https://firefly-api.adobe.io/v3/images/generate', {
method: 'POST',
headers: [
@@ -42,6 +43,8 @@ export default class FireflyManager extends ApiManager {
source: { url: structureUrl },
},
},
+ //prettier-ignore
+ style: { presets: styles }
}),
})
.then(response2 => response2.json().then(json => JSON.stringify((json.outputs?.[0] as { image: { url: string } })?.image)))
@@ -227,7 +230,7 @@ export default class FireflyManager extends ApiManager {
subscription: '/queryFireflyImageFromStructure',
secureHandler: async ({ req, res }) =>
this.uploadImageToDropbox(req.body.structureUrl).then(uploadUrl =>
- this.generateImageFromStructure(req.body.prompt, req.body.width, req.body.height, uploadUrl, req.body.strength).then(fire =>
+ this.generateImageFromStructure(req.body.prompt, req.body.width, req.body.height, uploadUrl, req.body.strength, req.body.styles).then(fire =>
DashUploadUtils.UploadImage(JSON.parse(fire ?? '').url).then(info => {
if (info instanceof Error) _invalid(res, info.message);
else _success(res, info);