fix(ui): typing issues related to trigger phrase changes

This commit is contained in:
psychedelicious 2024-03-07 15:36:58 +11:00
parent f0b815aa9b
commit 8fd9342712
2 changed files with 7 additions and 2 deletions

View File

@ -15,6 +15,7 @@ import type { ChangeEvent } from 'react';
import { useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useGetModelConfigQuery, useUpdateModelMutation } from 'services/api/endpoints/models';
import { isNonRefinerMainModelConfig } from 'services/api/types';
export const TriggerPhrases = () => {
const { t } = useTranslation();
@ -29,8 +30,11 @@ export const TriggerPhrases = () => {
}, []);
const triggerPhrases = useMemo(() => {
if (!modelConfig || !isNonRefinerMainModelConfig(modelConfig)) {
return [];
}
return modelConfig?.trigger_phrases || [];
}, [modelConfig?.trigger_phrases]);
}, [modelConfig]);
const errors = useMemo(() => {
const errors = [];

View File

@ -18,6 +18,7 @@ import {
useGetModelConfigQuery,
useGetTextualInversionModelsQuery,
} from 'services/api/endpoints/models';
import { isNonRefinerMainModelConfig } from 'services/api/types';
const noOptionsMessage = () => t('prompt.noMatchingTriggers');
@ -84,7 +85,7 @@ export const PromptTriggerSelect = memo(({ onSelect, onClose }: PromptTriggerSel
}
}
if (mainModelConfig && mainModelConfig.trigger_phrases?.length) {
if (mainModelConfig && isNonRefinerMainModelConfig(mainModelConfig) && mainModelConfig.trigger_phrases?.length) {
_options.push({
label: t('modelManager.mainModelTriggerPhrases'),
options: mainModelConfig.trigger_phrases.map((triggerPhrase) => ({