fix metadata references, add support for negative_conditioning syntax

This commit is contained in:
Mary Hipp
2023-05-25 14:47:16 -04:00
committed by psychedelicious
parent 3829ffbe66
commit 1e94d7739a
6 changed files with 30 additions and 40 deletions

View File

@ -21,8 +21,8 @@ export const useParameters = () => {
* Sets prompt with toast
*/
const recallPrompt = useCallback(
(prompt: unknown) => {
if (!isString(prompt)) {
(prompt: unknown, negativePrompt?: unknown) => {
if (!isString(prompt) || !isString(negativePrompt)) {
toaster({
title: t('toast.promptNotSet'),
description: t('toast.promptNotSetDesc'),
@ -33,7 +33,7 @@ export const useParameters = () => {
return;
}
setBothPrompts(prompt);
setBothPrompts(prompt, negativePrompt);
toaster({
title: t('toast.promptSet'),
status: 'info',
@ -112,12 +112,13 @@ export const useParameters = () => {
const recallAllParameters = useCallback(
(image: ImageDTO | undefined) => {
const type = image?.metadata?.type;
if (['txt2img', 'img2img', 'inpaint'].includes(String(type))) {
// not sure what this list should be
if (['t2l', 'l2l', 'inpaint'].includes(String(type))) {
dispatch(allParametersSet(image));
if (image?.metadata?.type === 'img2img') {
if (image?.metadata?.type === 'l2l') {
dispatch(setActiveTab('img2img'));
} else if (image?.metadata?.type === 'txt2img') {
} else if (image?.metadata?.type === 't2l') {
dispatch(setActiveTab('txt2img'));
}

View File

@ -12,16 +12,11 @@ const useSetBothPrompts = () => {
const dispatch = useAppDispatch();
return useCallback(
(inputPrompt: InvokeAI.Prompt) => {
const promptString =
typeof inputPrompt === 'string'
? inputPrompt
: promptToString(inputPrompt);
const [prompt, negativePrompt] = getPromptAndNegative(promptString);
dispatch(setPositivePrompt(prompt));
dispatch(setNegativePrompt(negativePrompt));
(inputPrompt: InvokeAI.Prompt, negativePrompt?: InvokeAI.Prompt) => {
dispatch(setPositivePrompt(inputPrompt));
if (negativePrompt) {
dispatch(setNegativePrompt(negativePrompt));
}
},
[dispatch]
);