diff options
| author | eleanor-park <eleanor_park@brown.edu> | 2025-01-14 17:25:47 +0100 |
|---|---|---|
| committer | eleanor-park <eleanor_park@brown.edu> | 2025-01-14 17:25:47 +0100 |
| commit | 85f60319ba7020b2976ed1063915a145a09ab381 (patch) | |
| tree | 60a1c2270717ff4a5e89fd079bdad1ad139ca4f7 /src/client/views/smartdraw | |
| parent | 859bb1b733901e4697f1d53781af725e4830c607 (diff) | |
| parent | 12f5a435ee6476e2e07ded0c9cdd597c70ca8af0 (diff) | |
Merge branch 'eleanor-gptdraw' of https://github.com/brown-dash/Dash-Web into eleanor-gptdraw
Diffstat (limited to 'src/client/views/smartdraw')
| -rw-r--r-- | src/client/views/smartdraw/DrawingFillHandler.tsx | 13 | ||||
| -rw-r--r-- | src/client/views/smartdraw/SmartDrawHandler.tsx | 8 |
2 files changed, 10 insertions, 11 deletions
diff --git a/src/client/views/smartdraw/DrawingFillHandler.tsx b/src/client/views/smartdraw/DrawingFillHandler.tsx index 57e75e86a..bc8f6c5e0 100644 --- a/src/client/views/smartdraw/DrawingFillHandler.tsx +++ b/src/client/views/smartdraw/DrawingFillHandler.tsx @@ -44,18 +44,17 @@ export class DrawingFillHandler { const { href } = ImageCast(imageField).url; const hrefParts = href.split('.'); const structureUrl = `${hrefParts.slice(0, -1).join('.')}_o.${hrefParts.lastElement()}`; - imageUrlToBase64(structureUrl) - .then((hrefBase64: string) => gptDescribeImage(hrefBase64)) - .then(prompt => { + return imageUrlToBase64(structureUrl) + .then(gptDescribeImage) + .then(prompt => Networking.PostToServer('/queryFireflyImageFromStructure', { prompt: `${user_prompt}, ${prompt}`, width: dims.width, height: dims.height, structure: structureUrl, strength: strength, presets: styles, styleUrl: styleUrl}) .then((info: Upload.ImageInformation) => DocumentViewInternal.addDocTabFunc(Docs.Create.ImageDocument(info.accessPaths.agnostic.client, - { ai: 'firefly', ai_firefly_prompt: user_prompt || prompt, _width: 500, data_nativeWidth: info.nativeWidth, data_nativeHeight: info.nativeHeight }), OpenWhere.addRight) - ).catch(e => alert("create image failed: " + e.toString())); // prettier-ignore - }); + { ai: 'firefly', title: user_prompt || prompt, ai_firefly_prompt: user_prompt || prompt, _width: 500, data_nativeWidth: info.nativeWidth, data_nativeHeight: info.nativeHeight }), OpenWhere.addRight) + ).catch(e => alert("create image failed: " + e.toString())) + ); // prettier-ignore } - return false; }); }; } diff --git a/src/client/views/smartdraw/SmartDrawHandler.tsx b/src/client/views/smartdraw/SmartDrawHandler.tsx index f635b5642..7db9ef133 100644 --- a/src/client/views/smartdraw/SmartDrawHandler.tsx +++ b/src/client/views/smartdraw/SmartDrawHandler.tsx @@ -271,16 +271,16 @@ export class SmartDrawHandler extends ObservableReactComponent<object> { createImageWithFirefly = (input: string, seed?: number, changeInPlace?: boolean): Promise<FireflyImageData> => { this._lastInput.text = input; const dims = FireflyDimensionsMap[this._imgDims]; - return Networking.PostToServer('/queryFireflyImage', { prompt: input, width: dims.width, height: dims.height, seed: seed }) + return Networking.PostToServer('/queryFireflyImage', { prompt: input, width: dims.width, height: dims.height, seed }) .then(img => { - const seed = img.accessPaths.agnostic.client.match(/\/(\d+)upload/)[1]; + const newseed = img.accessPaths.agnostic.client.match(/\/(\d+)upload/)[1]; if (!changeInPlace) { const imgDoc: Doc = Docs.Create.ImageDocument(img.accessPaths.agnostic.client, { title: input.match(/^(.*?)~~~.*$/)?.[1] || input, nativeWidth: dims.width, nativeHeight: dims.height, ai: 'firefly', - ai_firefly_seed: seed, + ai_firefly_seed: newseed, ai_firefly_prompt: input, }); DocumentViewInternal.addDocTabFunc(imgDoc, OpenWhere.addRight); @@ -306,7 +306,7 @@ export class SmartDrawHandler extends ObservableReactComponent<object> { case DocumentType.IMG: if (this._regenInput) { // if (this._selectedDoc) { - const newPrompt = `${doc.ai_firefly_prompt} ~~~ ${this._regenInput}`; + const newPrompt = doc.ai_firefly_prompt ? `${doc.ai_firefly_prompt} ~~~ ${this._regenInput}` : this._regenInput; return this.createImageWithFirefly(newPrompt, NumCast(doc?.ai_firefly_seed), changeInPlace); // } } |
