-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* UI in MM to create trigger phrases * add scheduler and vaePrecision to config * UI for configuring default settings for models' * hook MM default model settings up to API * add button to set default settings in parameters * pull out trigger phrases * back-end for default settings * lint * remove log; gi * ruff * ruff format --------- Co-authored-by: Mary Hipp <[email protected]>
- Loading branch information
Showing
28 changed files
with
1,122 additions
and
120 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
96 changes: 96 additions & 0 deletions
96
.../frontend/web/src/app/store/middleware/listenerMiddleware/listeners/setDefaultSettings.ts
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,96 @@ | ||
import type { AppStartListening } from 'app/store/middleware/listenerMiddleware'; | ||
import { setDefaultSettings } from 'features/parameters/store/actions'; | ||
import { | ||
setCfgRescaleMultiplier, | ||
setCfgScale, | ||
setScheduler, | ||
setSteps, | ||
vaePrecisionChanged, | ||
vaeSelected, | ||
} from 'features/parameters/store/generationSlice'; | ||
import { | ||
isParameterCFGRescaleMultiplier, | ||
isParameterCFGScale, | ||
isParameterPrecision, | ||
isParameterScheduler, | ||
isParameterSteps, | ||
zParameterVAEModel, | ||
} from 'features/parameters/types/parameterSchemas'; | ||
import { addToast } from 'features/system/store/systemSlice'; | ||
import { makeToast } from 'features/system/util/makeToast'; | ||
import { t } from 'i18next'; | ||
import { map } from 'lodash-es'; | ||
import { modelsApi } from 'services/api/endpoints/models'; | ||
|
||
export const addSetDefaultSettingsListener = (startAppListening: AppStartListening) => { | ||
startAppListening({ | ||
actionCreator: setDefaultSettings, | ||
effect: async (action, { dispatch, getState }) => { | ||
const state = getState(); | ||
|
||
const currentModel = state.generation.model; | ||
|
||
if (!currentModel) { | ||
return; | ||
} | ||
|
||
const metadata = await dispatch(modelsApi.endpoints.getModelMetadata.initiate(currentModel.key)).unwrap(); | ||
|
||
if (!metadata || !metadata.default_settings) { | ||
return; | ||
} | ||
|
||
const { vae, vae_precision, cfg_scale, cfg_rescale_multiplier, steps, scheduler } = metadata.default_settings; | ||
|
||
if (vae) { | ||
// we store this as "default" within default settings | ||
// to distinguish it from no default set | ||
if (vae === 'default') { | ||
dispatch(vaeSelected(null)); | ||
} else { | ||
const { data } = modelsApi.endpoints.getVaeModels.select()(state); | ||
const vaeArray = map(data?.entities); | ||
const validVae = vaeArray.find((model) => model.key === vae); | ||
|
||
const result = zParameterVAEModel.safeParse(validVae); | ||
if (!result.success) { | ||
return; | ||
} | ||
dispatch(vaeSelected(result.data)); | ||
} | ||
} | ||
|
||
if (vae_precision) { | ||
if (isParameterPrecision(vae_precision)) { | ||
dispatch(vaePrecisionChanged(vae_precision)); | ||
} | ||
} | ||
|
||
if (cfg_scale) { | ||
if (isParameterCFGScale(cfg_scale)) { | ||
dispatch(setCfgScale(cfg_scale)); | ||
} | ||
} | ||
|
||
if (cfg_rescale_multiplier) { | ||
if (isParameterCFGRescaleMultiplier(cfg_rescale_multiplier)) { | ||
dispatch(setCfgRescaleMultiplier(cfg_rescale_multiplier)); | ||
} | ||
} | ||
|
||
if (steps) { | ||
if (isParameterSteps(steps)) { | ||
dispatch(setSteps(steps)); | ||
} | ||
} | ||
|
||
if (scheduler) { | ||
if (isParameterScheduler(scheduler)) { | ||
dispatch(setScheduler(scheduler)); | ||
} | ||
} | ||
|
||
dispatch(addToast(makeToast({ title: t('toast.parameterSet', { parameter: 'Default settings' }) }))); | ||
}, | ||
}); | ||
}; |
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
Oops, something went wrong.