-
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): add fields for CLIP-L and CLIP-G, remove MainModelConfig type c…
…hanges
- Loading branch information
Mary Hipp
authored and
Mary Hipp
committed
Oct 30, 2024
1 parent
d409f44
commit 9543149
Showing
17 changed files
with
486 additions
and
59 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
61 changes: 61 additions & 0 deletions
61
...des/components/flow/nodes/Invocation/fields/inputs/CLIPGEmbedModelFieldInputComponent.tsx
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,61 @@ | ||
import { Combobox, Flex, FormControl, Tooltip } from '@invoke-ai/ui-library'; | ||
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; | ||
import { useGroupedModelCombobox } from 'common/hooks/useGroupedModelCombobox'; | ||
import { fieldCLIPGEmbedValueChanged } from 'features/nodes/store/nodesSlice'; | ||
import type { CLIPGEmbedModelFieldInputInstance, CLIPGEmbedModelFieldInputTemplate } from 'features/nodes/types/field'; | ||
import { memo, useCallback } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { useCLIPEmbedModels } from 'services/api/hooks/modelsByType'; | ||
import { type CLIPGEmbedModelConfig, isCLIPGEmbedModelConfig } from 'services/api/types'; | ||
|
||
import type { FieldComponentProps } from './types'; | ||
|
||
type Props = FieldComponentProps<CLIPGEmbedModelFieldInputInstance, CLIPGEmbedModelFieldInputTemplate>; | ||
|
||
const CLIPGEmbedModelFieldInputComponent = (props: Props) => { | ||
const { nodeId, field } = props; | ||
const { t } = useTranslation(); | ||
const disabledTabs = useAppSelector((s) => s.config.disabledTabs); | ||
const dispatch = useAppDispatch(); | ||
const [modelConfigs, { isLoading }] = useCLIPEmbedModels(); | ||
|
||
const _onChange = useCallback( | ||
(value: CLIPGEmbedModelConfig | null) => { | ||
if (!value) { | ||
return; | ||
} | ||
dispatch( | ||
fieldCLIPGEmbedValueChanged({ | ||
nodeId, | ||
fieldName: field.name, | ||
value, | ||
}) | ||
); | ||
}, | ||
[dispatch, field.name, nodeId] | ||
); | ||
const { options, value, onChange, placeholder, noOptionsMessage } = useGroupedModelCombobox({ | ||
modelConfigs: modelConfigs.filter((config) => isCLIPGEmbedModelConfig(config)), | ||
onChange: _onChange, | ||
isLoading, | ||
selectedModel: field.value, | ||
}); | ||
|
||
return ( | ||
<Flex w="full" alignItems="center" gap={2}> | ||
<Tooltip label={!disabledTabs.includes('models') && t('modelManager.starterModelsInModelManager')}> | ||
<FormControl className="nowheel nodrag" isDisabled={!options.length} isInvalid={!value}> | ||
<Combobox | ||
value={value} | ||
placeholder={placeholder} | ||
options={options} | ||
onChange={onChange} | ||
noOptionsMessage={noOptionsMessage} | ||
/> | ||
</FormControl> | ||
</Tooltip> | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default memo(CLIPGEmbedModelFieldInputComponent); |
61 changes: 61 additions & 0 deletions
61
...des/components/flow/nodes/Invocation/fields/inputs/CLIPLEmbedModelFieldInputComponent.tsx
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,61 @@ | ||
import { Combobox, Flex, FormControl, Tooltip } from '@invoke-ai/ui-library'; | ||
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; | ||
import { useGroupedModelCombobox } from 'common/hooks/useGroupedModelCombobox'; | ||
import { fieldCLIPLEmbedValueChanged } from 'features/nodes/store/nodesSlice'; | ||
import type { CLIPLEmbedModelFieldInputInstance, CLIPLEmbedModelFieldInputTemplate } from 'features/nodes/types/field'; | ||
import { memo, useCallback } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { useCLIPEmbedModels } from 'services/api/hooks/modelsByType'; | ||
import { type CLIPLEmbedModelConfig, isCLIPLEmbedModelConfig } from 'services/api/types'; | ||
|
||
import type { FieldComponentProps } from './types'; | ||
|
||
type Props = FieldComponentProps<CLIPLEmbedModelFieldInputInstance, CLIPLEmbedModelFieldInputTemplate>; | ||
|
||
const CLIPLEmbedModelFieldInputComponent = (props: Props) => { | ||
const { nodeId, field } = props; | ||
const { t } = useTranslation(); | ||
const disabledTabs = useAppSelector((s) => s.config.disabledTabs); | ||
const dispatch = useAppDispatch(); | ||
const [modelConfigs, { isLoading }] = useCLIPEmbedModels(); | ||
|
||
const _onChange = useCallback( | ||
(value: CLIPLEmbedModelConfig | null) => { | ||
if (!value) { | ||
return; | ||
} | ||
dispatch( | ||
fieldCLIPLEmbedValueChanged({ | ||
nodeId, | ||
fieldName: field.name, | ||
value, | ||
}) | ||
); | ||
}, | ||
[dispatch, field.name, nodeId] | ||
); | ||
const { options, value, onChange, placeholder, noOptionsMessage } = useGroupedModelCombobox({ | ||
modelConfigs: modelConfigs.filter((config) => isCLIPLEmbedModelConfig(config)), | ||
onChange: _onChange, | ||
isLoading, | ||
selectedModel: field.value, | ||
}); | ||
|
||
return ( | ||
<Flex w="full" alignItems="center" gap={2}> | ||
<Tooltip label={!disabledTabs.includes('models') && t('modelManager.starterModelsInModelManager')}> | ||
<FormControl className="nowheel nodrag" isDisabled={!options.length} isInvalid={!value}> | ||
<Combobox | ||
value={value} | ||
placeholder={placeholder} | ||
options={options} | ||
onChange={onChange} | ||
noOptionsMessage={noOptionsMessage} | ||
/> | ||
</FormControl> | ||
</Tooltip> | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default memo(CLIPLEmbedModelFieldInputComponent); |
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
Oops, something went wrong.