-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for generative background replace (#55)
- Loading branch information
1 parent
8c36dd2
commit 5522c30
Showing
8 changed files
with
104 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Action } from "../../internal/Action.js"; | ||
import { Qualifier } from "../../internal/qualifier/Qualifier.js"; | ||
import { IGenerativeBackgroundReplaceModel } from "../../internal/models/IEffectActionModel.js"; | ||
|
||
/** | ||
* @description Uses generative AI to replace background of your image with something else. | ||
* @extends SDK.Action | ||
* @memberOf Actions.Effect | ||
* @see Visit {@link Actions.Effect|Effect} for an example | ||
*/ | ||
class GenerativeBackgroundReplace extends Action { | ||
private _prompt: string; | ||
|
||
constructor() { | ||
super(); | ||
this._actionModel.actionType = "generativeBackgroundReplace"; | ||
} | ||
|
||
prompt(value: string): GenerativeBackgroundReplace { | ||
this._prompt = value; | ||
this._actionModel.prompt = value; | ||
|
||
return this; | ||
} | ||
|
||
protected prepareQualifiers(): void { | ||
if (!this._prompt) { | ||
this.addQualifier(new Qualifier("e", "gen_background_replace")); | ||
} else { | ||
this.addQualifier( | ||
new Qualifier("e", `gen_background_replace:prompt_${this._prompt}`) | ||
); | ||
} | ||
} | ||
|
||
static fromJson( | ||
actionModel: IGenerativeBackgroundReplaceModel | ||
): GenerativeBackgroundReplace { | ||
const { prompt } = actionModel; | ||
const result = new this(); | ||
|
||
return result.prompt(prompt); | ||
} | ||
} | ||
|
||
export { GenerativeBackgroundReplace }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters