From ef3e904839ea5ac425c24ab3eeee95583aa24786 Mon Sep 17 00:00:00 2001 From: Yi Date: Fri, 27 Dec 2024 13:57:54 +0800 Subject: [PATCH 1/5] feat: model-selector in Agent node (case: installed models) --- .../header/account-setting/index.tsx | 4 + .../model-provider-page/model-icon/index.tsx | 25 ++- .../model-provider-page/model-modal/Form.tsx | 3 + .../model-provider-page/model-name/index.tsx | 64 ++++--- .../agent-model-trigger.tsx | 180 ++++++++++++++++++ .../model-selector/popup-item.tsx | 38 ++-- web/app/components/plugins/card/index.tsx | 2 +- web/app/components/plugins/hooks.ts | 2 +- .../components/plugins/marketplace/utils.ts | 2 +- .../model-selector/index.tsx | 15 +- web/app/components/plugins/types.ts | 4 +- .../nodes/_base/components/agent-strategy.tsx | 1 + web/i18n/en-US/workflow.ts | 5 + web/i18n/zh-Hans/workflow.ts | 5 + web/service/use-strategy.ts | 2 +- 15 files changed, 285 insertions(+), 67 deletions(-) create mode 100644 web/app/components/header/account-setting/model-provider-page/model-parameter-modal/agent-model-trigger.tsx diff --git a/web/app/components/header/account-setting/index.tsx b/web/app/components/header/account-setting/index.tsx index b3409c226a..90a441a72d 100644 --- a/web/app/components/header/account-setting/index.tsx +++ b/web/app/components/header/account-setting/index.tsx @@ -36,6 +36,10 @@ const iconClassName = ` w-5 h-5 mr-2 ` +const scrolledClassName = ` + border-b shadow-xs bg-white/[.98] +` + type IAccountSettingProps = { onCancel: () => void activeTab?: string diff --git a/web/app/components/header/account-setting/model-provider-page/model-icon/index.tsx b/web/app/components/header/account-setting/model-provider-page/model-icon/index.tsx index 9f8dbd79d8..d8af591904 100644 --- a/web/app/components/header/account-setting/model-provider-page/model-icon/index.tsx +++ b/web/app/components/header/account-setting/model-provider-page/model-icon/index.tsx @@ -5,32 +5,37 @@ import type { } from '../declarations' import { useLanguage } from '../hooks' import { CubeOutline } from '@/app/components/base/icons/src/vender/line/shapes' -import { OpenaiViolet } from '@/app/components/base/icons/src/public/llm' +import { OpenaiBlue, OpenaiViolet } from '@/app/components/base/icons/src/public/llm' import cn from '@/utils/classnames' type ModelIconProps = { provider?: Model | ModelProvider modelName?: string className?: string + isDeprecated?: boolean } const ModelIcon: FC = ({ provider, className, modelName, + isDeprecated = false, }) => { const language = useLanguage() - - if (provider?.provider.includes('openai') && (modelName?.startsWith('gpt-4') || modelName?.includes('4o'))) - return + if (provider?.provider.includes('openai') && modelName?.includes('gpt-4o')) + return + if (provider?.provider.includes('openai') && modelName?.startsWith('gpt-4')) + return if (provider?.icon_small) { return ( - // eslint-disable-next-line @next/next/no-img-element - model-icon + +
+ model-icon +
) } diff --git a/web/app/components/header/account-setting/model-provider-page/model-modal/Form.tsx b/web/app/components/header/account-setting/model-provider-page/model-modal/Form.tsx index 6e54b939c3..6ade065af2 100644 --- a/web/app/components/header/account-setting/model-provider-page/model-modal/Form.tsx +++ b/web/app/components/header/account-setting/model-provider-page/model-modal/Form.tsx @@ -35,6 +35,7 @@ type FormProps< validatedSuccess?: boolean showOnVariableMap: Record isEditMode: boolean + isAgentStrategy?: boolean readonly?: boolean inputClassName?: string isShowDefaultValue?: boolean @@ -60,6 +61,7 @@ function Form< validatedSuccess, showOnVariableMap, isEditMode, + isAgentStrategy = false, readonly, inputClassName, isShowDefaultValue = false, @@ -278,6 +280,7 @@ function Form< popupClassName='!w-[387px]' isAdvancedMode isInWorkflow + isAgentStrategy={isAgentStrategy} value={value[variable]} setModel={model => handleModelChanged(variable, model)} readonly={readonly} diff --git a/web/app/components/header/account-setting/model-provider-page/model-name/index.tsx b/web/app/components/header/account-setting/model-provider-page/model-name/index.tsx index a955d9804a..bf25c49256 100644 --- a/web/app/components/header/account-setting/model-provider-page/model-name/index.tsx +++ b/web/app/components/header/account-setting/model-provider-page/model-name/index.tsx @@ -37,43 +37,45 @@ const ModelName: FC = ({ if (!modelItem) return null return ( -
+
{modelItem.label[language] || modelItem.label.en_US}
- { - showModelType && modelItem.model_type && ( - - {modelTypeFormat(modelItem.model_type)} - - ) - } - { - modelItem.model_properties.mode && showMode && ( - - {(modelItem.model_properties.mode as string).toLocaleUpperCase()} - - ) - } - { - showFeatures && modelItem.features?.map(feature => ( - - )) - } - { - showContextSize && modelItem.model_properties.context_size && ( - - {sizeFormat(modelItem.model_properties.context_size as number)} - - ) - } +
+ { + showModelType && modelItem.model_type && ( + + {modelTypeFormat(modelItem.model_type)} + + ) + } + { + modelItem.model_properties.mode && showMode && ( + + {(modelItem.model_properties.mode as string).toLocaleUpperCase()} + + ) + } + { + showFeatures && modelItem.features?.map(feature => ( + + )) + } + { + showContextSize && modelItem.model_properties.context_size && ( + + {sizeFormat(modelItem.model_properties.context_size as number)} + + ) + } +
{children}
) diff --git a/web/app/components/header/account-setting/model-provider-page/model-parameter-modal/agent-model-trigger.tsx b/web/app/components/header/account-setting/model-provider-page/model-parameter-modal/agent-model-trigger.tsx new file mode 100644 index 0000000000..4e03264ffd --- /dev/null +++ b/web/app/components/header/account-setting/model-provider-page/model-parameter-modal/agent-model-trigger.tsx @@ -0,0 +1,180 @@ +import type { FC } from 'react' +import { useTranslation } from 'react-i18next' +import type { + CustomConfigurationModelFixedFields, + ModelItem, + ModelProvider, +} from '../declarations' +import { + ConfigurationMethodEnum, + CustomConfigurationStatusEnum, +} from '../declarations' +import { UPDATE_MODEL_PROVIDER_CUSTOM_MODEL_LIST } from '../provider-added-card' +import { ModelStatusEnum } from '../declarations' +import { + useUpdateModelList, + useUpdateModelProviders, +} from '../hooks' +import ModelIcon from '../model-icon' +import ModelName from '../model-name' +import Button from '@/app/components/base/button' +import cn from '@/utils/classnames' +import { useProviderContext } from '@/context/provider-context' +import { useModalContextSelector } from '@/context/modal-context' +import { useEventEmitterContextContext } from '@/context/event-emitter' +import Tooltip from '@/app/components/base/tooltip' +import { RiEqualizer2Line, RiErrorWarningFill } from '@remixicon/react' + +export type AgentModelTriggerProps = { + open?: boolean + disabled?: boolean + currentProvider?: ModelProvider + currentModel?: ModelItem + providerName?: string + modelId?: string + hasDeprecated?: boolean +} + +const AgentModelTrigger: FC = ({ + disabled, + currentProvider, + currentModel, + providerName, + modelId, + hasDeprecated, +}) => { + const { t } = useTranslation() + const { modelProviders } = useProviderContext() + const setShowModelModal = useModalContextSelector(state => state.setShowModelModal) + const updateModelProviders = useUpdateModelProviders() + const updateModelList = useUpdateModelList() + const { eventEmitter } = useEventEmitterContextContext() + const modelProvider = modelProviders.find(item => item.provider === providerName) + const needsConfiguration = modelProvider?.custom_configuration.status === CustomConfigurationStatusEnum.noConfigure && !( + modelProvider.system_configuration.enabled === true + && modelProvider.system_configuration.quota_configurations.find( + item => item.quota_type === modelProvider.system_configuration.current_quota_type, + ) + ) + + const handleOpenModal = ( + provider: ModelProvider, + configurationMethod: ConfigurationMethodEnum, + CustomConfigurationModelFixedFields?: CustomConfigurationModelFixedFields, + ) => { + setShowModelModal({ + payload: { + currentProvider: provider, + currentConfigurationMethod: configurationMethod, + currentCustomConfigurationModelFixedFields: CustomConfigurationModelFixedFields, + }, + onSaveCallback: () => { + updateModelProviders() + + provider.supported_model_types.forEach((type) => { + updateModelList(type) + }) + + if (configurationMethod === ConfigurationMethodEnum.customizableModel + && provider.custom_configuration.status === CustomConfigurationStatusEnum.active) { + eventEmitter?.emit({ + type: UPDATE_MODEL_PROVIDER_CUSTOM_MODEL_LIST, + payload: provider.provider, + } as any) + + if (CustomConfigurationModelFixedFields?.__model_type) + updateModelList(CustomConfigurationModelFixedFields.__model_type) + } + }, + }) + } + + return ( +
+ {modelId ? ( + <> + {currentProvider && ( + + )} + {!currentProvider && ( + + )} + {currentModel && ( + + )} + {!currentModel && ( +
+
+ {modelId} +
+
+ )} + {needsConfiguration && ( + + )} + {!needsConfiguration && disabled && ( + + + + ) + } + + ) : ( + <> +
+ + {t('workflow.nodes.agent.configureModel')} + +
+
+ +
+ + )} + {currentProvider && currentModel && currentModel.status === ModelStatusEnum.active && ( +
+ +
+ )} +
+ ) +} + +export default AgentModelTrigger diff --git a/web/app/components/header/account-setting/model-provider-page/model-selector/popup-item.tsx b/web/app/components/header/account-setting/model-provider-page/model-selector/popup-item.tsx index 425fc2e34a..78e1d68357 100644 --- a/web/app/components/header/account-setting/model-provider-page/model-selector/popup-item.tsx +++ b/web/app/components/header/account-setting/model-provider-page/model-selector/popup-item.tsx @@ -77,28 +77,30 @@ const PopupItem: FC = ({
handleSelect(model.provider, modelItem)} > - - +
+ + +
{ defaultModel?.model === modelItem.model && defaultModel.provider === currentProvider.provider && ( diff --git a/web/app/components/plugins/card/index.tsx b/web/app/components/plugins/card/index.tsx index 9491d710f3..09b4ca73cb 100644 --- a/web/app/components/plugins/card/index.tsx +++ b/web/app/components/plugins/card/index.tsx @@ -44,7 +44,7 @@ const Card = ({ const locale = localeFromProps ? getLanguage(localeFromProps) : defaultLocale const { categoriesMap } = useCategories() const { category, type, name, org, label, brief, icon, verified } = payload - const isBundle = !['plugin', 'model', 'tool', 'extension', 'agent-strategy'].includes(type) + const isBundle = !['plugin', 'model', 'tool', 'extension', 'agent_strategy'].includes(type) const cornerMark = isBundle ? categoriesMap.bundle?.label : categoriesMap[category]?.label const getLocalizedText = (obj: Record | undefined) => obj?.[locale] || obj?.['en-US'] || obj?.en_US || '' diff --git a/web/app/components/plugins/hooks.ts b/web/app/components/plugins/hooks.ts index ab6bbf14fe..7c3003497b 100644 --- a/web/app/components/plugins/hooks.ts +++ b/web/app/components/plugins/hooks.ts @@ -44,7 +44,7 @@ export const useCategories = (translateFromOut?: TFunction) => { const categories = categoryKeys.map((category) => { if (category === 'agent') { return { - name: 'agent-strategy', + name: 'agent_strategy', label: t(`plugin.category.${category}s`), } } diff --git a/web/app/components/plugins/marketplace/utils.ts b/web/app/components/plugins/marketplace/utils.ts index 78d4437681..d8201156de 100644 --- a/web/app/components/plugins/marketplace/utils.ts +++ b/web/app/components/plugins/marketplace/utils.ts @@ -102,7 +102,7 @@ export const getMarketplaceListCondition = (pluginType: string) => { return 'category=tool' if (pluginType === PluginType.agent) - return 'category=agent-strategy' + return 'category=agent_strategy' if (pluginType === PluginType.model) return 'category=model' diff --git a/web/app/components/plugins/plugin-detail-panel/model-selector/index.tsx b/web/app/components/plugins/plugin-detail-panel/model-selector/index.tsx index 6bd750c8c3..a0917d93fa 100644 --- a/web/app/components/plugins/plugin-detail-panel/model-selector/index.tsx +++ b/web/app/components/plugins/plugin-detail-panel/model-selector/index.tsx @@ -13,6 +13,7 @@ import ModelSelector from '@/app/components/header/account-setting/model-provide import { useModelList, } from '@/app/components/header/account-setting/model-provider-page/hooks' +import AgentModelTrigger from '@/app/components/header/account-setting/model-provider-page/model-parameter-modal/agent-model-trigger' import Trigger from '@/app/components/header/account-setting/model-provider-page/model-parameter-modal/trigger' import type { TriggerProps } from '@/app/components/header/account-setting/model-provider-page/model-parameter-modal/trigger' import { @@ -34,6 +35,7 @@ export type ModelParameterModalProps = { renderTrigger?: (v: TriggerProps) => ReactNode readonly?: boolean isInWorkflow?: boolean + isAgentStrategy?: boolean scope?: string } @@ -46,6 +48,7 @@ const ModelParameterModal: FC = ({ renderTrigger, readonly, isInWorkflow, + isAgentStrategy, scope = ModelTypeEnum.textGeneration, }) => { const { t } = useTranslation() @@ -168,8 +171,16 @@ const ModelParameterModal: FC = ({ providerName: value?.provider, modelId: value?.model, }) - : ( - + : { validating={false} showOnVariableMap={{}} isEditMode={true} + isAgentStrategy={true} fieldLabelClassName='uppercase' customRenderField={renderField} /> diff --git a/web/i18n/en-US/workflow.ts b/web/i18n/en-US/workflow.ts index ecce13b5b2..30e13b527d 100644 --- a/web/i18n/en-US/workflow.ts +++ b/web/i18n/en-US/workflow.ts @@ -714,6 +714,8 @@ const translation = { install: 'Install', installing: 'Installing', }, + configureModel: 'Configure Model', + notAuthorized: 'Not Authorized', model: 'model', toolbox: 'toolbox', strategyNotSet: 'Agentic strategy Not Set', @@ -723,6 +725,9 @@ const translation = { toolNotInstallTooltip: '{{tool}} is not installed', toolNotAuthorizedTooltip: '{{tool}} Not Authorized', strategyNotInstallTooltip: '{{strategy}} is not installed', + modelSelectorTooltips: { + deprecated: 'This model is deprecated', + }, }, }, tracing: { diff --git a/web/i18n/zh-Hans/workflow.ts b/web/i18n/zh-Hans/workflow.ts index 0935791136..b4291c64fc 100644 --- a/web/i18n/zh-Hans/workflow.ts +++ b/web/i18n/zh-Hans/workflow.ts @@ -717,12 +717,17 @@ const translation = { model: '模型', toolbox: '工具箱', strategyNotSet: '代理策略未设置', + configureModel: '配置模型', + notAuthorized: '未授权', tools: '工具', maxIterations: '最大迭代次数', modelNotInstallTooltip: '此模型未安装', toolNotInstallTooltip: '{{tool}} 未安装', toolNotAuthorizedTooltip: '{{tool}} 未授权', strategyNotInstallTooltip: '{{strategy}} 未安装', + modelSelectorTooltips: { + deprecated: '此模型已弃用', + }, }, }, tracing: { diff --git a/web/service/use-strategy.ts b/web/service/use-strategy.ts index e6f6c4b607..cbc09509b3 100644 --- a/web/service/use-strategy.ts +++ b/web/service/use-strategy.ts @@ -7,7 +7,7 @@ import { useQuery, } from '@tanstack/react-query' -const NAME_SPACE = 'agent-strategy' +const NAME_SPACE = 'agent_strategy' const useStrategyListKey = [NAME_SPACE, 'strategyList'] export const useStrategyProviders = () => { From 69a6556f5239e4f9567f9f33d1e24de274fa40c2 Mon Sep 17 00:00:00 2001 From: JzoNg Date: Fri, 27 Dec 2024 14:09:24 +0800 Subject: [PATCH 2/5] tool item --- .../plugins/plugin-detail-panel/index.tsx | 4 + .../tool-selector/index.tsx | 37 +++++- .../tool-selector/tool-item.tsx | 120 ++++++++++++++++++ 3 files changed, 155 insertions(+), 6 deletions(-) create mode 100644 web/app/components/plugins/plugin-detail-panel/tool-selector/tool-item.tsx diff --git a/web/app/components/plugins/plugin-detail-panel/index.tsx b/web/app/components/plugins/plugin-detail-panel/index.tsx index 3378d75b5b..fcc31b938d 100644 --- a/web/app/components/plugins/plugin-detail-panel/index.tsx +++ b/web/app/components/plugins/plugin-detail-panel/index.tsx @@ -33,6 +33,9 @@ const PluginDetailPanel: FC = ({ console.log('tool change', val) setValue(val) } + const testDelete = () => { + setValue(undefined) + } if (!detail) return null @@ -63,6 +66,7 @@ const PluginDetailPanel: FC = ({ testChange(item)} + onDelete={testDelete} />
diff --git a/web/app/components/plugins/plugin-detail-panel/tool-selector/index.tsx b/web/app/components/plugins/plugin-detail-panel/tool-selector/index.tsx index 732c94103f..3e7993f761 100644 --- a/web/app/components/plugins/plugin-detail-panel/tool-selector/index.tsx +++ b/web/app/components/plugins/plugin-detail-panel/tool-selector/index.tsx @@ -2,6 +2,7 @@ import type { FC } from 'react' import React, { useMemo, useState } from 'react' import { useTranslation } from 'react-i18next' +import Link from 'next/link' import { RiArrowLeftLine, RiArrowRightUpLine, @@ -12,6 +13,7 @@ import { PortalToFollowElemTrigger, } from '@/app/components/base/portal-to-follow-elem' import ToolTrigger from '@/app/components/plugins/plugin-detail-panel/tool-selector/tool-trigger' +import ToolItem from '@/app/components/plugins/plugin-detail-panel/tool-selector/tool-item' import ToolPicker from '@/app/components/workflow/block-selector/tool-picker' import Button from '@/app/components/base/button' import Indicator from '@/app/components/header/indicator' @@ -54,6 +56,7 @@ type Props = { parameters?: Record extra?: Record }) => void + onDelete?: () => void supportAddCustomTool?: boolean scope?: string } @@ -63,6 +66,7 @@ const ToolSelector: FC = ({ placement = 'left', offset = 4, onSelect, + onDelete, scope, }) => { const { t } = useTranslation() @@ -155,12 +159,33 @@ const ToolSelector: FC = ({ className='w-full' onClick={handleTriggerClick} > - + {!value?.provider_name && ( + + )} + {value?.provider_name && ( + setShowSettingAuth(true)} + // uninstalled + errorTip={
+

{t('workflow.nodes.agent.pluginNotInstalled')}

+

{t('workflow.nodes.agent.pluginNotInstalledDesc')}

+

+ {t('workflow.nodes.agent.linkToPlugin')} +

+
} + /> + )}
diff --git a/web/app/components/plugins/plugin-detail-panel/tool-selector/tool-item.tsx b/web/app/components/plugins/plugin-detail-panel/tool-selector/tool-item.tsx new file mode 100644 index 0000000000..a20e0d6e6f --- /dev/null +++ b/web/app/components/plugins/plugin-detail-panel/tool-selector/tool-item.tsx @@ -0,0 +1,120 @@ +'use client' +import React, { useState } from 'react' +import { useTranslation } from 'react-i18next' +import { + RiDeleteBinLine, + RiEqualizer2Line, + RiErrorWarningFill, +} from '@remixicon/react' +import AppIcon from '@/app/components/base/app-icon' +import Switch from '@/app/components/base/switch' +import Button from '@/app/components/base/button' +import Indicator from '@/app/components/header/indicator' +import ActionButton from '@/app/components/base/action-button' +import Tooltip from '@/app/components/base/tooltip' +import { InstallPluginButton } from '@/app/components/workflow/nodes/_base/components/install-plugin-button' +import cn from '@/utils/classnames' + +type Props = { + icon?: any + providerName?: string + toolName?: string + showSwitch?: boolean + switchValue?: boolean + onSwitchChange?: (value: boolean) => void + onDelete?: () => void + noAuth?: boolean + onAuth?: () => void + isError?: boolean + errorTip?: any + uninstalled?: boolean + isInstalling?: boolean + onInstall?: () => void + open: boolean +} + +const ToolItem = ({ + open, + icon, + providerName, + toolName, + showSwitch, + switchValue, + onSwitchChange, + onDelete, + noAuth, + onAuth, + uninstalled, + isInstalling, + onInstall, + isError, + errorTip, +}: Props) => { + const { t } = useTranslation() + const providerNameText = providerName?.split('/').pop() + const isTransparent = uninstalled || isError + const [isDeleting, setIsDeleting] = useState(false) + + return ( +
+
+ {typeof icon === 'string' &&
} + {typeof icon !== 'string' && } +
+
+
{providerNameText}
+
{toolName}
+
+
+ {!noAuth && !isError && !uninstalled && ( + + + + )} +
setIsDeleting(true)} + onMouseLeave={() => setIsDeleting(false)} + > + +
+
+ {!isError && !uninstalled && !noAuth && showSwitch && ( + + )} + {!isError && !uninstalled && noAuth && ( + + )} + {!isError && uninstalled && ( + { + e.stopPropagation() + onInstall?.() + }} /> + )} + {isError && ( + +
+ +
+
+ )} +
+ ) +} + +export default ToolItem From 08c517dd990dcfa5f47038f05379a587a581ac0b Mon Sep 17 00:00:00 2001 From: Joel Date: Fri, 27 Dec 2024 14:20:05 +0800 Subject: [PATCH 3/5] feat: iteration support parallel --- .../install-from-marketplace/index.tsx | 1 - .../workflow/run/utils/format-log/index.ts | 2 +- .../run/utils/format-log/iteration/index.ts | 13 ++++++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/web/app/components/plugins/install-plugin/install-from-marketplace/index.tsx b/web/app/components/plugins/install-plugin/install-from-marketplace/index.tsx index f1126e09c8..046806ee08 100644 --- a/web/app/components/plugins/install-plugin/install-from-marketplace/index.tsx +++ b/web/app/components/plugins/install-plugin/install-from-marketplace/index.tsx @@ -38,7 +38,6 @@ const InstallFromMarketplace: React.FC = ({ const updateModelProviders = useUpdateModelProviders() const invalidateAllToolProviders = useInvalidateAllToolProviders() const invalidateInstalledPluginList = useInvalidateInstalledPluginList() - // TODO: check installed in beta version. const getTitle = useCallback(() => { if (isBundle && step === InstallStep.installed) diff --git a/web/app/components/workflow/run/utils/format-log/index.ts b/web/app/components/workflow/run/utils/format-log/index.ts index 4a974fc35a..8239f6ca33 100644 --- a/web/app/components/workflow/run/utils/format-log/index.ts +++ b/web/app/components/workflow/run/utils/format-log/index.ts @@ -13,7 +13,7 @@ const formatToTracingNodeList = (list: NodeTracing[], t: any) => { const formattedAgentList = formatAgentNode(allItems) const formattedRetryList = formatRetryNode(formattedAgentList) // retry one node // would change the structure of the list. Iteration and parallel can include each other. - const formattedIterationList = formatIterationNode(formattedRetryList) + const formattedIterationList = formatIterationNode(formattedRetryList, t) const formattedParallelList = formatParallelNode(formattedIterationList, t) const result = formattedParallelList diff --git a/web/app/components/workflow/run/utils/format-log/iteration/index.ts b/web/app/components/workflow/run/utils/format-log/iteration/index.ts index 7583f40b1a..ca3dad7fb0 100644 --- a/web/app/components/workflow/run/utils/format-log/iteration/index.ts +++ b/web/app/components/workflow/run/utils/format-log/iteration/index.ts @@ -1,6 +1,6 @@ import { BlockEnum } from '@/app/components/workflow/types' import type { NodeTracing } from '@/types/workflow' - +import formatParallelNode from '../parallel' function addChildrenToIterationNode(iterationNode: NodeTracing, childrenNodes: NodeTracing[]): NodeTracing { const details: NodeTracing[][] = [] childrenNodes.forEach((item) => { @@ -18,7 +18,7 @@ function addChildrenToIterationNode(iterationNode: NodeTracing, childrenNodes: N } } -const format = (list: NodeTracing[]): NodeTracing[] => { +const format = (list: NodeTracing[], t: any): NodeTracing[] => { const iterationNodeIds = list .filter(item => item.node_type === BlockEnum.Iteration) .map(item => item.node_id) @@ -36,7 +36,14 @@ const format = (list: NodeTracing[]): NodeTracing[] => { item.status = 'failed' item.error = error.error } - return addChildrenToIterationNode(item, childrenNodes) + const addedChildrenList = addChildrenToIterationNode(item, childrenNodes) + // handle parallel node in iteration node + if (addedChildrenList.details && addedChildrenList.details.length > 0) { + addedChildrenList.details = addedChildrenList.details.map((row) => { + return formatParallelNode(row, t) + }) + } + return addedChildrenList } return item From ed6c9625e8c0b3edfaae86f0e8de88fc415f5d94 Mon Sep 17 00:00:00 2001 From: JzoNg Date: Fri, 27 Dec 2024 14:20:28 +0800 Subject: [PATCH 4/5] fix scope features --- .../plugin-detail-panel/model-selector/index.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/web/app/components/plugins/plugin-detail-panel/model-selector/index.tsx b/web/app/components/plugins/plugin-detail-panel/model-selector/index.tsx index a0917d93fa..ce8b70776a 100644 --- a/web/app/components/plugins/plugin-detail-panel/model-selector/index.tsx +++ b/web/app/components/plugins/plugin-detail-panel/model-selector/index.tsx @@ -55,7 +55,18 @@ const ModelParameterModal: FC = ({ const { isAPIKeySet } = useProviderContext() const [open, setOpen] = useState(false) const scopeArray = scope.split('&') - const scopeFeatures = scopeArray.slice(1) || [] + const scopeFeatures = useMemo(() => { + if (scopeArray.includes('all')) + return [] + return scopeArray.filter(item => ![ + ModelTypeEnum.textGeneration, + ModelTypeEnum.textEmbedding, + ModelTypeEnum.rerank, + ModelTypeEnum.moderation, + ModelTypeEnum.speech2text, + ModelTypeEnum.tts, + ].includes(item as ModelTypeEnum)) + }, [scopeArray]) const { data: textGenerationList } = useModelList(ModelTypeEnum.textGeneration) const { data: textEmbeddingList } = useModelList(ModelTypeEnum.textEmbedding) From 31cca291b756c0ff01338d5aeb00954c324ec3e2 Mon Sep 17 00:00:00 2001 From: Joel Date: Fri, 27 Dec 2024 14:21:54 +0800 Subject: [PATCH 5/5] chore: remove test page --- .../plugins/test/card/actions.ts | 14 --- .../(commonLayout)/plugins/test/card/page.tsx | 118 ------------------ .../plugins/test/tools-picker/page.tsx | 22 ---- .../plugins/test/update/page.tsx | 67 ---------- 4 files changed, 221 deletions(-) delete mode 100644 web/app/(commonLayout)/plugins/test/card/actions.ts delete mode 100644 web/app/(commonLayout)/plugins/test/card/page.tsx delete mode 100644 web/app/(commonLayout)/plugins/test/tools-picker/page.tsx delete mode 100644 web/app/(commonLayout)/plugins/test/update/page.tsx diff --git a/web/app/(commonLayout)/plugins/test/card/actions.ts b/web/app/(commonLayout)/plugins/test/card/actions.ts deleted file mode 100644 index 799d6ee8db..0000000000 --- a/web/app/(commonLayout)/plugins/test/card/actions.ts +++ /dev/null @@ -1,14 +0,0 @@ -'use server' - -import { revalidatePath } from 'next/cache' - -// Server Actions -export async function handleDelete() { - // revalidatePath only invalidates the cache when the included path is next visited. - revalidatePath('/') -} - -export async function fetchPluginDetail(org: string, name: string) { - // Fetch plugin detail TODO - return { org, name } -} diff --git a/web/app/(commonLayout)/plugins/test/card/page.tsx b/web/app/(commonLayout)/plugins/test/card/page.tsx deleted file mode 100644 index 86e0da56bf..0000000000 --- a/web/app/(commonLayout)/plugins/test/card/page.tsx +++ /dev/null @@ -1,118 +0,0 @@ -'use client' -import Card from '@/app/components/plugins/card' -import { customTool, extensionDallE, modelGPT4, toolNotion } from '@/app/components/plugins/card/card-mock' -// import PluginItem from '@/app/components/plugins/plugin-item' -import CardMoreInfo from '@/app/components/plugins/card/card-more-info' -// import ProviderCard from '@/app/components/plugins/provider-card' -import Badge from '@/app/components/base/badge' -import InstallBundle from '@/app/components/plugins/install-plugin/install-bundle' -import { useBoolean } from 'ahooks' -import LoadingError from '@/app/components/plugins/install-plugin/base/loading-error' - -const PluginList = () => { - const pluginList = [toolNotion, extensionDallE, modelGPT4, customTool] - const [isShow, { - setFalse: hide, - }] = useBoolean(true) - - return ( -
- - {isShow && ( - - ) - } -
- {/*

Dify Plugin list

*/} - {/*
- {pluginList.map((plugin, index) => ( - - ))} -
*/} - -

Install Plugin / Package under bundle

-
- - } - /> -
- {/*

Installed

-
- -
*/} - - {/*

Install model provide

-
- {pluginList.map((plugin, index) => ( - - ))} -
*/} - -
-

Marketplace Plugin list

-
- {pluginList.map((plugin, index) => ( - - } - /> - ))} -
-
-
- ) -} - -// export const metadata = { -// title: 'Plugins - Card', -// } - -export default PluginList diff --git a/web/app/(commonLayout)/plugins/test/tools-picker/page.tsx b/web/app/(commonLayout)/plugins/test/tools-picker/page.tsx deleted file mode 100644 index 0b6242a42e..0000000000 --- a/web/app/(commonLayout)/plugins/test/tools-picker/page.tsx +++ /dev/null @@ -1,22 +0,0 @@ -'use client' -import React from 'react' -import ToolPicker from '@/app/components/workflow/block-selector/tool-picker' - -const ToolsPicker = () => { - const [show, setShow] = React.useState(true) - return ( -
- Click me
} - isShow={show} - onShowChange={setShow} - disabled={false} - supportAddCustomTool={true} - onSelect={() => { }} - /> -
- - ) -} - -export default ToolsPicker diff --git a/web/app/(commonLayout)/plugins/test/update/page.tsx b/web/app/(commonLayout)/plugins/test/update/page.tsx deleted file mode 100644 index 9d78b45979..0000000000 --- a/web/app/(commonLayout)/plugins/test/update/page.tsx +++ /dev/null @@ -1,67 +0,0 @@ -'use client' -import { toolNeko } from '@/app/components/plugins/card/card-mock' -import { PluginSource } from '@/app/components/plugins/types' -import { useModalContext } from '@/context/modal-context' -import React from 'react' - -const UpdatePlugin = () => { - const { setShowUpdatePluginModal } = useModalContext() - const handleUpdateFromMarketPlace = () => { - setShowUpdatePluginModal({ - payload: { - type: PluginSource.marketplace, - marketPlace: { - originalPackageInfo: { - id: 'langgenius/neko:0.0.1@9e57d693739287c0efdc96847d7ed959ca93f70aa704471f2eb7ed3313821824', - payload: toolNeko as any, - }, - targetPackageInfo: { - id: 'target_xxx', - version: '1.2.3', - }, - }, - }, - onCancelCallback: () => { - console.log('canceled') - }, - onSaveCallback: () => { - console.log('saved') - }, - }) - } - const handleUpdateFromGithub = () => { - setShowUpdatePluginModal({ - payload: { - type: PluginSource.github, - github: { - originalPackageInfo: { - id: '111', - repo: 'aaa/bbb', - version: 'xxx', - url: 'aaa/bbb', - currVersion: '1.2.3', - currPackage: 'pack1', - } as any, - }, - }, - onCancelCallback: () => { - console.log('canceled') - }, - onSaveCallback: () => { - console.log('saved') - }, - }) - } - - return ( -
-
更新组件
-
-
从 Marketplace
-
从 GitHub
-
-
- ) -} - -export default React.memo(UpdatePlugin)