From 52537c9e6ba339fe9b342568f9cc976fe491d6aa Mon Sep 17 00:00:00 2001 From: AkaraChen Date: Tue, 31 Dec 2024 15:53:38 +0800 Subject: [PATCH] fix: model deprecated in model list --- .../components/workflow/nodes/agent/node.tsx | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/web/app/components/workflow/nodes/agent/node.tsx b/web/app/components/workflow/nodes/agent/node.tsx index 948a9ef0d2..cef0a4330b 100644 --- a/web/app/components/workflow/nodes/agent/node.tsx +++ b/web/app/components/workflow/nodes/agent/node.tsx @@ -8,11 +8,33 @@ import type { ToolIconProps } from './components/tool-icon' import { ToolIcon } from './components/tool-icon' import useConfig from './use-config' import { useTranslation } from 'react-i18next' -import { FormTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations' +import { FormTypeEnum, ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations' +import { useModelList } from '@/app/components/header/account-setting/model-provider-page/hooks' + +const useAllModel = () => { + const { data: textGeneration } = useModelList(ModelTypeEnum.textGeneration) + const { data: moderation } = useModelList(ModelTypeEnum.moderation) + const { data: rerank } = useModelList(ModelTypeEnum.rerank) + const { data: speech2text } = useModelList(ModelTypeEnum.speech2text) + const { data: textEmbedding } = useModelList(ModelTypeEnum.textEmbedding) + const { data: tts } = useModelList(ModelTypeEnum.tts) + const models = useMemo(() => { + return textGeneration + .concat(moderation) + .concat(rerank) + .concat(speech2text) + .concat(textEmbedding) + .concat(tts) + }, [textGeneration, moderation, rerank, speech2text, textEmbedding, tts]) + if (!textGeneration || !moderation || !rerank || !speech2text || !textEmbedding || !tts) + return undefined + return models +} const AgentNode: FC> = (props) => { const { inputs, currentStrategy } = useConfig(props.id, props.data) const { t } = useTranslation() + const modelList = useAllModel() const models = useMemo(() => { if (!inputs) return [] // if selected, show in node @@ -73,7 +95,7 @@ const AgentNode: FC> = (props) => { {inputs.agent_strategy_label} : } - {models.length > 0 && 0 && modelList && {t('workflow.nodes.agent.model')} } @@ -81,7 +103,8 @@ const AgentNode: FC> = (props) => { {models.map((model) => { return