diff --git a/web/app/(commonLayout)/plugins/test/tools-picker/page.tsx b/web/app/(commonLayout)/plugins/test/tools-picker/page.tsx index 37c3b3b1cf..0b6242a42e 100644 --- a/web/app/(commonLayout)/plugins/test/tools-picker/page.tsx +++ b/web/app/(commonLayout)/plugins/test/tools-picker/page.tsx @@ -3,11 +3,19 @@ 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={() => { }} + /> + + ) } diff --git a/web/app/components/app/annotation/index.tsx b/web/app/components/app/annotation/index.tsx index e287f6970f..46ecdd5480 100644 --- a/web/app/components/app/annotation/index.tsx +++ b/web/app/components/app/annotation/index.tsx @@ -27,7 +27,7 @@ import AnnotationFullModal from '@/app/components/billing/annotation-full/modal' import { Settings04 } from '@/app/components/base/icons/src/vender/line/general' import type { App } from '@/types/app' -type Props = { +interface Props { appDetail: App } @@ -283,7 +283,6 @@ const Annotation: FC = ({ if ( embeddingModel.embedding_model_name !== annotationConfig?.embedding_model?.embedding_model_name || embeddingModel.embedding_provider_name !== annotationConfig?.embedding_model?.embedding_provider_name - || embeddingModel.plugin_id !== annotationConfig?.embedding_model?.plugin_id ) { const { job_id: jobId }: any = await updateAnnotationStatus(appDetail.id, AnnotationEnableStatus.enable, embeddingModel, score) await ensureJobCompleted(jobId, AnnotationEnableStatus.enable) diff --git a/web/app/components/app/annotation/type.ts b/web/app/components/app/annotation/type.ts index 28811f4617..5df6f51ace 100644 --- a/web/app/components/app/annotation/type.ts +++ b/web/app/components/app/annotation/type.ts @@ -23,9 +23,8 @@ export type HitHistoryItem = { } export type EmbeddingModelConfig = { - plugin_id: string - embedding_model_name: string embedding_provider_name: string + embedding_model_name: string } export enum AnnotationEnableStatus { diff --git a/web/app/components/app/configuration/config/agent/agent-tools/index.tsx b/web/app/components/app/configuration/config/agent/agent-tools/index.tsx index b66f331f5b..bbc352b9b4 100644 --- a/web/app/components/app/configuration/config/agent/agent-tools/index.tsx +++ b/web/app/components/app/configuration/config/agent/agent-tools/index.tsx @@ -27,10 +27,12 @@ import { MAX_TOOLS_NUM } from '@/config' import { AlertTriangle } from '@/app/components/base/icons/src/vender/solid/alertsAndFeedback' import Tooltip from '@/app/components/base/tooltip' import { DefaultToolIcon } from '@/app/components/base/icons/src/public/other' -import AddToolModal from '@/app/components/tools/add-tool-modal' +// import AddToolModal from '@/app/components/tools/add-tool-modal' import ConfigCredential from '@/app/components/tools/setting/build-in/config-credentials' import { updateBuiltInToolCredential } from '@/service/tools' import cn from '@/utils/classnames' +import ToolPicker from '@/app/components/workflow/block-selector/tool-picker' +import type { ToolDefaultValue } from '@/app/components/workflow/block-selector/types' type AgentToolWithMoreInfo = AgentTool & { icon: any; collection?: Collection } | null const AgentTools: FC = () => { @@ -81,6 +83,21 @@ const AgentTools: FC = () => { const [isDeleting, setIsDeleting] = useState(-1) + const handleSelectTool = (tool: ToolDefaultValue) => { + const newModelConfig = produce(modelConfig, (draft) => { + draft.agentConfig.tools.push({ + provider_id: tool.provider_id, + provider_type: tool.provider_type as CollectionType, + provider_name: tool.provider_name, + tool_name: tool.tool_name, + tool_label: tool.tool_label, + tool_parameters: {}, + enabled: true, + }) + }) + setModelConfig(newModelConfig) + } + return ( <> { {tools.length < MAX_TOOLS_NUM && ( <>
- setIsShowChooseTool(true)} /> + } + isShow={isShowChooseTool} + onShowChange={setIsShowChooseTool} + disabled={false} + supportAddCustomTool + onSelect={handleSelectTool} + /> )} @@ -125,8 +149,8 @@ const AgentTools: FC = () => { {item.isDeleted && } {!item.isDeleted && (
- {typeof item.icon === 'string' &&
} - {typeof item.icon !== 'string' && } + {typeof item.icon === 'string' &&
} + {typeof item.icon !== 'string' && }
)}
{ ))}
- {isShowChooseTool && ( - setIsShowChooseTool(false)} /> - )} {isShowSettingTool && ( void isInWorkflow?: boolean @@ -71,7 +71,6 @@ const ConfigContent: FC = ({ ? { ...rerankDefaultModel, provider: rerankDefaultModel.provider.provider, - plugin_id: rerankDefaultModel.provider.plugin_id, } : undefined, ) @@ -81,14 +80,12 @@ const ConfigContent: FC = ({ return { provider_name: datasetConfigs.reranking_model.reranking_provider_name, model_name: datasetConfigs.reranking_model.reranking_model_name, - plugin_id: datasetConfigs.reranking_model.reranking_plugin_id, } } else if (rerankDefaultModel) { return { provider_name: rerankDefaultModel.provider.provider, model_name: rerankDefaultModel.model, - plugin_id: rerankDefaultModel.provider.plugin_id, } } })() @@ -175,7 +172,7 @@ const ConfigContent: FC = ({ return false return datasetConfigs.reranking_enable - }, [canManuallyToggleRerank, datasetConfigs.reranking_enable, isRerankDefaultModelValid]) + }, [canManuallyToggleRerank, datasetConfigs.reranking_enable]) const handleDisabledSwitchClick = useCallback(() => { if (!currentRerankModel && !showRerankModel) @@ -303,14 +300,13 @@ const ConfigContent: FC = ({
{ onChange({ ...datasetConfigs, reranking_model: { reranking_provider_name: v.provider, reranking_model_name: v.model, - reranking_plugin_id: v.plugin_id, }, }) }} @@ -388,7 +384,6 @@ const ConfigContent: FC = ({ portalToFollowElemContentClassName='!z-[1002]' isAdvancedMode={true} mode={model?.mode} - pluginId={model?.plugin_id} provider={model?.provider} completionParams={model?.completion_params} modelId={model?.name} diff --git a/web/app/components/app/configuration/debug/debug-with-multiple-model/model-parameter-trigger.tsx b/web/app/components/app/configuration/debug/debug-with-multiple-model/model-parameter-trigger.tsx index 380d7363f6..155ebe21ca 100644 --- a/web/app/components/app/configuration/debug/debug-with-multiple-model/model-parameter-trigger.tsx +++ b/web/app/components/app/configuration/debug/debug-with-multiple-model/model-parameter-trigger.tsx @@ -36,13 +36,12 @@ const ModelParameterTrigger: FC = ({ const language = useLanguage() const index = multipleModelConfigs.findIndex(v => v.id === modelAndParameter.id) - const handleSelectModel = ({ modelId, provider, pluginId }: { modelId: string; provider: string; pluginId: string }) => { + const handleSelectModel = ({ modelId, provider }: { modelId: string; provider: string }) => { const newModelConfigs = [...multipleModelConfigs] newModelConfigs[index] = { ...newModelConfigs[index], model: modelId, provider, - plugin_id: pluginId, } onMultipleModelConfigsChange(true, newModelConfigs) } @@ -59,7 +58,6 @@ const ModelParameterTrigger: FC = ({ } diff --git a/web/app/components/app/configuration/index.tsx b/web/app/components/app/configuration/index.tsx index c74881d7f8..af50fc65c3 100644 --- a/web/app/components/app/configuration/index.tsx +++ b/web/app/components/app/configuration/index.tsx @@ -72,7 +72,7 @@ import { SupportUploadFileTypes } from '@/app/components/workflow/types' import NewFeaturePanel from '@/app/components/base/features/new-feature-panel' import { fetchFileUploadConfig } from '@/service/common' -type PublishConfig = { +interface PublishConfig { modelConfig: ModelConfig completionParams: FormValue } @@ -156,7 +156,6 @@ const Configuration: FC = () => { const setCompletionParams = (value: FormValue) => { const params = { ...value } - // eslint-disable-next-line ts/no-use-before-define if ((!params.stop || params.stop.length === 0) && (modeModeTypeRef.current === ModelModeType.completion)) { params.stop = getTempStop() setTempStop([]) @@ -165,7 +164,6 @@ const Configuration: FC = () => { } const [modelConfig, doSetModelConfig] = useState({ - plugin_id: 'langgenius', provider: 'openai', model_id: 'gpt-3.5-turbo', mode: ModelModeType.unset, @@ -200,7 +198,6 @@ const Configuration: FC = () => { reranking_model: { reranking_provider_name: '', reranking_model_name: '', - reranking_plugin_id: '', }, top_k: DATASET_DEFAULT.top_k, score_threshold_enabled: false, @@ -282,7 +279,6 @@ const Configuration: FC = () => { reranking_model: restConfigs.reranking_model && { reranking_provider_name: restConfigs.reranking_model.reranking_provider_name, reranking_model_name: restConfigs.reranking_model.reranking_model_name, - reranking_plugin_id: restConfigs.reranking_model.reranking_plugin_id, }, retrieval_model, score_threshold_enabled, @@ -324,7 +320,6 @@ const Configuration: FC = () => { textGenerationModelList, } = useTextGenerationCurrentProviderAndModelAndModelList( { - plugin_id: modelConfig.plugin_id, provider: modelConfig.provider, model: modelConfig.model_id, }, @@ -355,7 +350,6 @@ const Configuration: FC = () => { const [canReturnToSimpleMode, setCanReturnToSimpleMode] = useState(true) const setPromptMode = async (mode: PromptMode) => { if (mode === PromptMode.advanced) { - // eslint-disable-next-line ts/no-use-before-define await migrateToDefaultPrompt() setCanReturnToSimpleMode(true) } @@ -551,7 +545,6 @@ const Configuration: FC = () => { const config = { modelConfig: { - plugin_id: model.plugin_id, provider: model.provider, model_id: model.name, mode: model.mode, @@ -770,8 +763,8 @@ const Configuration: FC = () => { handleMultipleModelConfigsChange( true, [ - { id: `${Date.now()}`, model: modelConfig.model_id, plugin_id: modelConfig.plugin_id, provider: modelConfig.provider, parameters: completionParams }, - { id: `${Date.now()}-no-repeat`, model: '', plugin_id: '', provider: '', parameters: {} }, + { id: `${Date.now()}`, model: modelConfig.model_id, provider: modelConfig.provider, parameters: completionParams }, + { id: `${Date.now()}-no-repeat`, model: '', provider: '', parameters: {} }, ], ) setAppSiderbarExpand('collapse') @@ -893,7 +886,6 @@ const Configuration: FC = () => { void - workflowVariables?: InputVar[] -} - -// regex to match the {{}} and replace it with a span -const regex = /\{\{([^}]+)\}\}/g - -const OpeningStatement: FC = ({ - onChange, - readonly, - promptVariables = [], - onAutoAddPromptVariable, - workflowVariables = [], -}) => { - const { t } = useTranslation() - const featureStore = useFeaturesStore() - const openingStatement = useFeatures(s => s.features.opening) - const value = openingStatement?.opening_statement || '' - const suggestedQuestions = openingStatement?.suggested_questions || [] - const [notIncludeKeys, setNotIncludeKeys] = useState([]) - - const hasValue = !!(value || '').trim() - const inputRef = useRef(null) - - const [isFocus, { setTrue: didSetFocus, setFalse: setBlur }] = useBoolean(false) - - const setFocus = () => { - didSetFocus() - setTimeout(() => { - const input = inputRef.current - if (input) { - input.focus() - input.setSelectionRange(input.value.length, input.value.length) - } - }, 0) - } - - const [tempValue, setTempValue] = useState(value) - useEffect(() => { - setTempValue(value || '') - }, [value]) - - const [tempSuggestedQuestions, setTempSuggestedQuestions] = useState(suggestedQuestions || []) - const notEmptyQuestions = tempSuggestedQuestions.filter(question => !!question && question.trim()) - const coloredContent = (tempValue || '') - .replace(//g, '>') - .replace(regex, varHighlightHTML({ name: '$1' })) // `{{$1}}` - .replace(/\n/g, '
') - - const handleEdit = () => { - if (readonly) - return - setFocus() - } - - const [isShowConfirmAddVar, { setTrue: showConfirmAddVar, setFalse: hideConfirmAddVar }] = useBoolean(false) - - const handleCancel = () => { - setBlur() - setTempValue(value) - setTempSuggestedQuestions(suggestedQuestions) - } - - const handleConfirm = () => { - const keys = getInputKeys(tempValue) - const promptKeys = promptVariables.map(item => item.key) - const workflowVariableKeys = workflowVariables.map(item => item.variable) - let notIncludeKeys: string[] = [] - - if (promptKeys.length === 0 && workflowVariables.length === 0) { - if (keys.length > 0) - notIncludeKeys = keys - } - else { - if (workflowVariables.length > 0) - notIncludeKeys = keys.filter(key => !workflowVariableKeys.includes(key)) - - else notIncludeKeys = keys.filter(key => !promptKeys.includes(key)) - } - - if (notIncludeKeys.length > 0) { - setNotIncludeKeys(notIncludeKeys) - showConfirmAddVar() - return - } - setBlur() - const { getState } = featureStore! - const { - features, - setFeatures, - } = getState() - - const newFeatures = produce(features, (draft) => { - if (draft.opening) { - draft.opening.opening_statement = tempValue - draft.opening.suggested_questions = tempSuggestedQuestions - } - }) - setFeatures(newFeatures) - - if (onChange) - onChange(newFeatures) - } - - const cancelAutoAddVar = () => { - const { getState } = featureStore! - const { - features, - setFeatures, - } = getState() - - const newFeatures = produce(features, (draft) => { - if (draft.opening) - draft.opening.opening_statement = tempValue - }) - setFeatures(newFeatures) - - if (onChange) - onChange(newFeatures) - hideConfirmAddVar() - setBlur() - } - - const autoAddVar = () => { - const { getState } = featureStore! - const { - features, - setFeatures, - } = getState() - - const newFeatures = produce(features, (draft) => { - if (draft.opening) - draft.opening.opening_statement = tempValue - }) - setFeatures(newFeatures) - if (onChange) - onChange(newFeatures) - onAutoAddPromptVariable([...notIncludeKeys.map(key => getNewVar(key, 'string'))]) - hideConfirmAddVar() - setBlur() - } - - const headerRight = !readonly ? ( - isFocus ? ( -
- - -
- ) : ( - - ) - ) : null - - const renderQuestions = () => { - return isFocus ? ( -
-
-
-
{t('appDebug.openingStatement.openingQuestion')}
-
·
-
{tempSuggestedQuestions.length}/{MAX_QUESTION_NUM}
-
-
-
- { - return { - id: index, - name, - } - })} - setList={list => setTempSuggestedQuestions(list.map(item => item.name))} - handle='.handle' - ghostClass="opacity-50" - animation={150} - > - {tempSuggestedQuestions.map((question, index) => { - return ( -
-
- - - -
- { - const value = e.target.value - setTempSuggestedQuestions(tempSuggestedQuestions.map((item, i) => { - if (index === i) - return value - - return item - })) - }} - className={'w-full overflow-x-auto pl-1.5 pr-8 text-sm leading-9 text-gray-900 border-0 grow h-9 bg-transparent focus:outline-none cursor-pointer rounded-lg'} - /> - -
{ - setTempSuggestedQuestions(tempSuggestedQuestions.filter((_, i) => index !== i)) - }} - > - -
-
- ) - })}
- {tempSuggestedQuestions.length < MAX_QUESTION_NUM && ( -
{ setTempSuggestedQuestions([...tempSuggestedQuestions, '']) }} - className='mt-1 flex items-center h-9 px-3 gap-2 rounded-lg cursor-pointer text-gray-400 bg-gray-100 hover:bg-gray-200'> - -
{t('appDebug.variableConfig.addOption')}
-
- )} -
- ) : ( -
- {notEmptyQuestions.map((question, index) => { - return ( -
- {question} -
- ) - })} -
- ) - } - - return ( - - - - } - headerRight={headerRight} - hasHeaderBottomBorder={!hasValue} - isFocus={isFocus} - > -
- {(hasValue || (!hasValue && isFocus)) ? ( - <> - {isFocus - ? ( -
- -
- ) - : ( -
- )} - {renderQuestions()} - ) : ( -
{t('appDebug.openingStatement.noDataPlaceHolder')}
- )} - - {isShowConfirmAddVar && ( - - )} - -
-
- ) -} -export default React.memo(OpeningStatement) diff --git a/web/app/components/base/features/new-feature-panel/annotation-reply/config-param-modal.tsx b/web/app/components/base/features/new-feature-panel/annotation-reply/config-param-modal.tsx index 6309498d20..801f1348ee 100644 --- a/web/app/components/base/features/new-feature-panel/annotation-reply/config-param-modal.tsx +++ b/web/app/components/base/features/new-feature-panel/annotation-reply/config-param-modal.tsx @@ -18,7 +18,6 @@ type Props = { isShow: boolean onHide: () => void onSave: (embeddingModel: { - plugin_id: string embedding_provider_name: string embedding_model_name: string }, score: number) => void @@ -44,13 +43,11 @@ const ConfigParamModal: FC = ({ const [isLoading, setLoading] = useState(false) const [embeddingModel, setEmbeddingModel] = useState(oldAnnotationConfig.embedding_model ? { - plugin_id: oldAnnotationConfig.embedding_model.plugin_id, providerName: oldAnnotationConfig.embedding_model.embedding_provider_name, modelName: oldAnnotationConfig.embedding_model.embedding_model_name, } : (embeddingsDefaultModel ? { - plugin_id: embeddingsDefaultModel.provider.plugin_id, providerName: embeddingsDefaultModel.provider.provider, modelName: embeddingsDefaultModel.model, } @@ -70,7 +67,6 @@ const ConfigParamModal: FC = ({ } setLoading(true) await onSave({ - plugin_id: embeddingModel.plugin_id, embedding_provider_name: embeddingModel.providerName, embedding_model_name: embeddingModel.modelName, }, annotationConfig.score_threshold) @@ -111,14 +107,12 @@ const ConfigParamModal: FC = ({
{ setEmbeddingModel({ - plugin_id: val.plugin_id, providerName: val.provider, modelName: val.model, }) diff --git a/web/app/components/header/account-setting/index.tsx b/web/app/components/header/account-setting/index.tsx index c530d3268f..9df7065733 100644 --- a/web/app/components/header/account-setting/index.tsx +++ b/web/app/components/header/account-setting/index.tsx @@ -199,13 +199,13 @@ export default function AccountSetting({ )}
+ {activeMenu === 'provider' && } {activeMenu === 'members' && } {activeMenu === 'billing' && } - {activeMenu === 'language' && } - {activeMenu === 'provider' && } {activeMenu === 'data-source' && } {activeMenu === 'api-based-extension' && } {activeMenu === 'custom' && } + {activeMenu === 'language' && }
diff --git a/web/app/components/header/account-setting/model-provider-page/declarations.ts b/web/app/components/header/account-setting/model-provider-page/declarations.ts index 930ae4b852..c50a17c6b2 100644 --- a/web/app/components/header/account-setting/model-provider-page/declarations.ts +++ b/web/app/components/header/account-setting/model-provider-page/declarations.ts @@ -1,6 +1,6 @@ export type FormValue = Record -export type TypeWithI18N = { +export interface TypeWithI18N { en_US: T zh_Hans: T [key: string]: T @@ -17,7 +17,7 @@ export enum FormTypeEnum { file = 'file', } -export type FormOption = { +export interface FormOption { label: TypeWithI18N value: string show_on: FormShowOnObject[] @@ -89,12 +89,12 @@ export enum CustomConfigurationStatusEnum { noConfigure = 'no-configure', } -export type FormShowOnObject = { +export interface FormShowOnObject { variable: string value: string } -export type CredentialFormSchemaBase = { +export interface CredentialFormSchemaBase { variable: string label: TypeWithI18N type: FormTypeEnum @@ -112,7 +112,7 @@ export type CredentialFormSchemaRadio = CredentialFormSchemaBase & { options: Fo export type CredentialFormSchemaSecretInput = CredentialFormSchemaBase & { placeholder?: TypeWithI18N } export type CredentialFormSchema = CredentialFormSchemaTextInput | CredentialFormSchemaSelect | CredentialFormSchemaRadio | CredentialFormSchemaSecretInput -export type ModelItem = { +export interface ModelItem { model: string label: TypeWithI18N model_type: ModelTypeEnum @@ -141,7 +141,7 @@ export enum QuotaUnitEnum { credits = 'credits', } -export type QuotaConfiguration = { +export interface QuotaConfiguration { quota_type: CurrentSystemQuotaTypeEnum quota_unit: QuotaUnitEnum quota_limit: number @@ -150,8 +150,7 @@ export type QuotaConfiguration = { is_valid: boolean } -export type ModelProvider = { - plugin_id: string +export interface ModelProvider { provider: string label: TypeWithI18N description?: TypeWithI18N @@ -185,8 +184,7 @@ export type ModelProvider = { } } -export type Model = { - plugin_id: string +export interface Model { provider: string icon_large: TypeWithI18N icon_small: TypeWithI18N @@ -195,29 +193,27 @@ export type Model = { status: ModelStatusEnum } -export type DefaultModelResponse = { +export interface DefaultModelResponse { model: string model_type: ModelTypeEnum provider: { - plugin_id: string provider: string icon_large: TypeWithI18N icon_small: TypeWithI18N } } -export type DefaultModel = { - plugin_id: string +export interface DefaultModel { provider: string model: string } -export type CustomConfigurationModelFixedFields = { +export interface CustomConfigurationModelFixedFields { __model_name: string __model_type: ModelTypeEnum } -export type ModelParameterRule = { +export interface ModelParameterRule { default?: number | string | boolean | string[] help?: TypeWithI18N label: TypeWithI18N @@ -232,7 +228,7 @@ export type ModelParameterRule = { tagPlaceholder?: TypeWithI18N } -export type ModelLoadBalancingConfigEntry = { +export interface ModelLoadBalancingConfigEntry { /** model balancing config entry id */ id?: string /** is config entry enabled */ @@ -247,7 +243,7 @@ export type ModelLoadBalancingConfigEntry = { ttl?: number } -export type ModelLoadBalancingConfig = { +export interface ModelLoadBalancingConfig { enabled: boolean configs: ModelLoadBalancingConfigEntry[] } diff --git a/web/app/components/header/account-setting/model-provider-page/hooks.ts b/web/app/components/header/account-setting/model-provider-page/hooks.ts index e34c09d651..54396cc538 100644 --- a/web/app/components/header/account-setting/model-provider-page/hooks.ts +++ b/web/app/components/header/account-setting/model-provider-page/hooks.ts @@ -11,7 +11,6 @@ import type { DefaultModel, DefaultModelResponse, Model, - ModelProvider, ModelTypeEnum, } from './declarations' import { @@ -37,12 +36,11 @@ export const useSystemDefaultModelAndModelList: UseDefaultModelAndModelList = ( modelList, ) => { const currentDefaultModel = useMemo(() => { - const currentProvider = modelList.find(provider => provider.provider === defaultModel?.provider.provider && provider.plugin_id === defaultModel?.provider.plugin_id) + const currentProvider = modelList.find(provider => provider.provider === defaultModel?.provider.provider) const currentModel = currentProvider?.models.find(model => model.model === defaultModel?.model) const currentDefaultModel = currentProvider && currentModel && { model: currentModel.model, provider: currentProvider.provider, - plugin_id: currentProvider.plugin_id, } return currentDefaultModel @@ -64,20 +62,20 @@ export const useLanguage = () => { } export const useProviderCredentialsAndLoadBalancing = ( - provider: ModelProvider, + provider: string, configurationMethod: ConfigurationMethodEnum, configured?: boolean, currentCustomConfigurationModelFixedFields?: CustomConfigurationModelFixedFields, ) => { const { data: predefinedFormSchemasValue, mutate: mutatePredefined } = useSWR( (configurationMethod === ConfigurationMethodEnum.predefinedModel && configured) - ? `/workspaces/current/model-providers/${provider.plugin_id}/${provider.provider}/credentials` + ? `/workspaces/current/model-providers/${provider}/credentials` : null, fetchModelProviderCredentials, ) const { data: customFormSchemasValue, mutate: mutateCustomized } = useSWR( (configurationMethod === ConfigurationMethodEnum.customizableModel && currentCustomConfigurationModelFixedFields) - ? `/workspaces/current/model-providers/${provider.plugin_id}/${provider.provider}/models/credentials?model=${currentCustomConfigurationModelFixedFields?.__model_name}&model_type=${currentCustomConfigurationModelFixedFields?.__model_type}` + ? `/workspaces/current/model-providers/${provider}/models/credentials?model=${currentCustomConfigurationModelFixedFields?.__model_name}&model_type=${currentCustomConfigurationModelFixedFields?.__model_type}` : null, fetchModelProviderCredentials, ) @@ -174,11 +172,7 @@ export const useModelListAndDefaultModelAndCurrentProviderAndModel = (type: Mode const { modelList, defaultModel } = useModelListAndDefaultModel(type) const { currentProvider, currentModel } = useCurrentProviderAndModel( modelList, - { - plugin_id: defaultModel?.provider.plugin_id || '', - provider: defaultModel?.provider.provider || '', - model: defaultModel?.model || '', - }, + { provider: defaultModel?.provider.provider || '', model: defaultModel?.model || '' }, ) return { @@ -199,7 +193,6 @@ export const useUpdateModelList = () => { return updateModelList } -// deprecated ??? export const useAnthropicBuyQuota = () => { const [loading, setLoading] = useState(false) diff --git a/web/app/components/header/account-setting/model-provider-page/index.tsx b/web/app/components/header/account-setting/model-provider-page/index.tsx index e3542bc327..6d508f0de1 100644 --- a/web/app/components/header/account-setting/model-provider-page/index.tsx +++ b/web/app/components/header/account-setting/model-provider-page/index.tsx @@ -1,16 +1,15 @@ -import { useMemo, useState } from 'react' +import { useEffect, useMemo, useState } from 'react' import { useTranslation } from 'react-i18next' import Link from 'next/link' +import { useDebounce } from 'ahooks' import { RiAlertFill, RiArrowDownSLine, RiArrowRightUpLine, RiBrainLine, } from '@remixicon/react' -import { useContext } from 'use-context-selector' import SystemModelSelector from './system-model-selector' import ProviderAddedCard, { UPDATE_MODEL_PROVIDER_CUSTOM_MODEL_LIST } from './provider-added-card' -// import ProviderCard from './provider-card' import type { CustomConfigurationModelFixedFields, ModelProvider, @@ -26,16 +25,24 @@ import { useUpdateModelProviders, } from './hooks' import Divider from '@/app/components/base/divider' +import Loading from '@/app/components/base/loading' import ProviderCard from '@/app/components/plugins/provider-card' -import I18n from '@/context/i18n' import { useProviderContext } from '@/context/provider-context' import { useModalContextSelector } from '@/context/modal-context' import { useEventEmitterContextContext } from '@/context/event-emitter' +import { + useMarketplacePlugins, +} from '@/app/components/plugins/marketplace/hooks' +import { PluginType } from '@/app/components/plugins/types' +import { MARKETPLACE_URL_PREFIX } from '@/config' import cn from '@/utils/classnames' -import { extensionDallE, modelGPT4, toolNotion } from '@/app/components/plugins/card/card-mock' +type Props = { + searchText: string +} -const ModelProviderPage = () => { +const ModelProviderPage = ({ searchText }: Props) => { + const debouncedSearchText = useDebounce(searchText, { wait: 500 }) const { t } = useTranslation() const { eventEmitter } = useEventEmitterContextContext() const updateModelProviders = useUpdateModelProviders() @@ -67,6 +74,18 @@ const ModelProviderPage = () => { return [configuredProviders, notConfiguredProviders] }, [providers]) + const [filteredConfiguredProviders, filteredNotConfiguredProviders] = useMemo(() => { + const filteredConfiguredProviders = configuredProviders.filter( + provider => provider.provider.toLowerCase().includes(debouncedSearchText.toLowerCase()) + || Object.values(provider.label).some(text => text.toLowerCase().includes(debouncedSearchText.toLowerCase())), + ) + const filteredNotConfiguredProviders = notConfiguredProviders.filter( + provider => provider.provider.toLowerCase().includes(debouncedSearchText.toLowerCase()) + || Object.values(provider.label).some(text => text.toLowerCase().includes(debouncedSearchText.toLowerCase())), + ) + + return [filteredConfiguredProviders, filteredNotConfiguredProviders] + }, [configuredProviders, debouncedSearchText, notConfiguredProviders]) const handleOpenModal = ( provider: ModelProvider, @@ -91,7 +110,7 @@ const ModelProviderPage = () => { if (configurationMethod === ConfigurationMethodEnum.customizableModel && provider.custom_configuration.status === CustomConfigurationStatusEnum.active) { eventEmitter?.emit({ type: UPDATE_MODEL_PROVIDER_CUSTOM_MODEL_LIST, - payload: provider, + payload: provider.provider, } as any) if (CustomConfigurationModelFixedFields?.__model_type) @@ -102,10 +121,28 @@ const ModelProviderPage = () => { } const [collapse, setCollapse] = useState(false) - const { locale } = useContext(I18n) - // TODO #Plugin list API# - const pluginList = [toolNotion, extensionDallE, modelGPT4] + const { + plugins, + queryPlugins, + queryPluginsWithDebounced, + isLoading: isPluginsLoading, + } = useMarketplacePlugins() + + useEffect(() => { + if (searchText) { + queryPluginsWithDebounced({ + query: searchText, + category: PluginType.model, + }) + } + else { + queryPlugins({ + query: searchText, + category: PluginType.model, + }) + } + }, [queryPlugins, queryPluginsWithDebounced, searchText]) return (
@@ -132,7 +169,7 @@ const ModelProviderPage = () => { />
- {!configuredProviders?.length && ( + {!filteredConfiguredProviders?.length && (
@@ -141,9 +178,9 @@ const ModelProviderPage = () => {
{t('common.modelProvider.emptyProviderTip')}
)} - {!!configuredProviders?.length && ( + {!!filteredConfiguredProviders?.length && (
- {configuredProviders?.map(provider => ( + {filteredConfiguredProviders?.map(provider => ( { ))}
)} - {false && !!notConfiguredProviders?.length && ( + {!!filteredNotConfiguredProviders?.length && ( <>
{t('common.modelProvider.configureRequired')}
- {notConfiguredProviders?.map(provider => ( + {filteredNotConfiguredProviders?.map(provider => ( {
{t('common.modelProvider.discoverMore')} - + Dify Marketplace
- {!collapse && ( + {!collapse && !isPluginsLoading && (
- {pluginList.map((plugin, index) => ( - + {plugins.map(plugin => ( + ))}
)} + {!collapse && isPluginsLoading && } ) diff --git a/web/app/components/header/account-setting/model-provider-page/model-modal/index.tsx b/web/app/components/header/account-setting/model-provider-page/model-modal/index.tsx index a1a56b19d1..967bcccdca 100644 --- a/web/app/components/header/account-setting/model-provider-page/model-modal/index.tsx +++ b/web/app/components/header/account-setting/model-provider-page/model-modal/index.tsx @@ -72,7 +72,7 @@ const ModelModal: FC = ({ loadBalancing: originalConfig, mutate, } = useProviderCredentialsAndLoadBalancing( - provider, + provider.provider, configurateMethod, providerFormSchemaPredefined && provider.custom_configuration.status === CustomConfigurationStatusEnum.active, currentCustomConfigurationModelFixedFields, @@ -229,7 +229,6 @@ const ModelModal: FC = ({ setLoading(true) const res = await saveCredentials( providerFormSchemaPredefined, - provider.plugin_id, provider.provider, encodeSecretValues(value), { @@ -256,7 +255,6 @@ const ModelModal: FC = ({ const res = await removeCredentials( providerFormSchemaPredefined, - provider.plugin_id, provider.provider, value, ) diff --git a/web/app/components/header/account-setting/model-provider-page/model-modal/model-load-balancing-entry-modal.tsx b/web/app/components/header/account-setting/model-provider-page/model-modal/model-load-balancing-entry-modal.tsx index bd453ce59b..1c318b9baf 100644 --- a/web/app/components/header/account-setting/model-provider-page/model-modal/model-load-balancing-entry-modal.tsx +++ b/web/app/components/header/account-setting/model-provider-page/model-modal/model-load-balancing-entry-modal.tsx @@ -209,7 +209,6 @@ const ModelLoadBalancingEntryModal: FC = ({ const res = await validateLoadBalancingCredentials( providerFormSchemaPredefined, - provider.plugin_id, provider.provider, { ...value, diff --git a/web/app/components/header/account-setting/model-provider-page/model-parameter-modal/index.tsx b/web/app/components/header/account-setting/model-provider-page/model-parameter-modal/index.tsx index c489778732..e21aa33d7a 100644 --- a/web/app/components/header/account-setting/model-provider-page/model-parameter-modal/index.tsx +++ b/web/app/components/header/account-setting/model-provider-page/model-parameter-modal/index.tsx @@ -38,9 +38,8 @@ export type ModelParameterModalProps = { isAdvancedMode: boolean mode: string modelId: string - pluginId: string provider: string - setModel: (model: { modelId: string; provider: string; pluginId: string; mode?: string; features?: string[] }) => void + setModel: (model: { modelId: string; provider: string; mode?: string; features?: string[] }) => void completionParams: FormValue onCompletionParamsChange: (newParams: FormValue) => void hideDebugWithMultipleModel?: boolean @@ -75,7 +74,6 @@ const ModelParameterModal: FC = ({ portalToFollowElemContentClassName, isAdvancedMode, modelId, - pluginId, provider, setModel, completionParams, @@ -90,17 +88,13 @@ const ModelParameterModal: FC = ({ const { t } = useTranslation() const { isAPIKeySet } = useProviderContext() const [open, setOpen] = useState(false) - const { data: parameterRulesData, isLoading } = useSWR((provider && modelId) ? `/workspaces/current/model-providers/${pluginId}/${provider}/models/parameter-rules?model=${modelId}` : null, fetchModelParameterRules) + const { data: parameterRulesData, isLoading } = useSWR((provider && modelId) ? `/workspaces/current/model-providers/${provider}/models/parameter-rules?model=${modelId}` : null, fetchModelParameterRules) const { currentProvider, currentModel, activeTextGenerationModelList, } = useTextGenerationCurrentProviderAndModelAndModelList( - { - plugin_id: pluginId, - provider, - model: modelId, - }, + { provider, model: modelId }, ) const hasDeprecated = !currentProvider || !currentModel @@ -118,12 +112,11 @@ const ModelParameterModal: FC = ({ }) } - const handleChangeModel = ({ provider, model, plugin_id }: DefaultModel) => { + const handleChangeModel = ({ provider, model }: DefaultModel) => { const targetProvider = activeTextGenerationModelList.find(modelItem => modelItem.provider === provider) const targetModelItem = targetProvider?.models.find(modelItem => modelItem.model === model) setModel({ modelId: model, - pluginId: plugin_id, provider, mode: targetModelItem?.model_properties.mode as string, features: targetModelItem?.features || [], @@ -208,7 +201,7 @@ const ModelParameterModal: FC = ({ {t('common.modelProvider.model').toLocaleUpperCase()} = ({ defaultModel, ) - const handleSelect = (pluginId: string, provider: string, model: ModelItem) => { + const handleSelect = (provider: string, model: ModelItem) => { setOpen(false) if (onSelect) - onSelect({ plugin_id: pluginId, provider, model: model.model }) + onSelect({ provider, model: model.model }) } const handleToggle = () => { 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 ce62494220..d62131ac4c 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 @@ -25,7 +25,7 @@ import Tooltip from '@/app/components/base/tooltip' type PopupItemProps = { defaultModel?: DefaultModel model: Model - onSelect: (pluginId: string, provider: string, model: ModelItem) => void + onSelect: (provider: string, model: ModelItem) => void } const PopupItem: FC = ({ defaultModel, @@ -39,11 +39,11 @@ const PopupItem: FC = ({ const updateModelList = useUpdateModelList() const updateModelProviders = useUpdateModelProviders() const currentProvider = modelProviders.find(provider => provider.provider === model.provider)! - const handleSelect = (pluginId: string, provider: string, modelItem: ModelItem) => { + const handleSelect = (provider: string, modelItem: ModelItem) => { if (modelItem.status !== ModelStatusEnum.active) return - onSelect(pluginId, provider, modelItem) + onSelect(provider, modelItem) } const handleOpenModelModal = () => { setShowModelModal({ @@ -80,7 +80,7 @@ const PopupItem: FC = ({ group relative flex items-center px-3 py-1.5 h-8 rounded-lg ${modelItem.status === ModelStatusEnum.active ? 'cursor-pointer hover:bg-gray-50' : 'cursor-not-allowed hover:bg-gray-50/60'} `} - onClick={() => handleSelect(model.plugin_id, model.provider, modelItem)} + onClick={() => handleSelect(model.provider, modelItem)} > void + onSelect: (provider: string, model: ModelItem) => void } const Popup: FC = ({ defaultModel, diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/credential-panel.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/credential-panel.tsx index 9d0c979de2..e7f865f198 100644 --- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/credential-panel.tsx +++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/credential-panel.tsx @@ -41,7 +41,7 @@ const CredentialPanel: FC = ({ const handleChangePriority = async (key: PreferredProviderTypeEnum) => { const res = await changeModelProviderPriority({ - url: `/workspaces/current/model-providers/${provider.plugin_id}/${provider.provider}/preferred-provider-type`, + url: `/workspaces/current/model-providers/${provider.provider}/preferred-provider-type`, body: { preferred_provider_type: key, }, @@ -57,7 +57,7 @@ const CredentialPanel: FC = ({ eventEmitter?.emit({ type: UPDATE_MODEL_PROVIDER_CUSTOM_MODEL_LIST, - payload: provider, + payload: provider.provider, } as any) } } diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/index.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/index.tsx index 7b7702d6b8..46ef6add24 100644 --- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/index.tsx +++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/index.tsx @@ -52,12 +52,12 @@ const ProviderAddedCard: FC = ({ const showQuota = systemConfig.enabled && [...MODEL_PROVIDER_QUOTA_GET_PAID].includes(provider.provider) && !IS_CE_EDITION const showCredential = configurationMethods.includes(ConfigurationMethodEnum.predefinedModel) && isCurrentWorkspaceManager - const getModelList = async (pluginID: string, providerName: string) => { + const getModelList = async (providerName: string) => { if (loading) return try { setLoading(true) - const modelsData = await fetchModelProviderModelList(`/workspaces/current/model-providers/${pluginID}/${providerName}/models`) + const modelsData = await fetchModelProviderModelList(`/workspaces/current/model-providers/${providerName}/models`) setModelList(modelsData.data) setCollapsed(false) setFetched(true) @@ -72,12 +72,12 @@ const ProviderAddedCard: FC = ({ return } - getModelList(provider.plugin_id, provider.provider) + getModelList(provider.provider) } eventEmitter?.useSubscription((v: any) => { - if (v?.type === UPDATE_MODEL_PROVIDER_CUSTOM_MODEL_LIST && v.payload.provider === provider.provider) - getModelList(v.payload.plugin_id, v.payload.provider) + if (v?.type === UPDATE_MODEL_PROVIDER_CUSTOM_MODEL_LIST && v.payload === provider.provider) + getModelList(v.payload) }) return ( @@ -172,7 +172,7 @@ const ProviderAddedCard: FC = ({ models={modelList} onCollapse={() => setCollapsed(true)} onConfig={currentCustomConfigurationModelFixedFields => onOpenModal(ConfigurationMethodEnum.customizableModel, currentCustomConfigurationModelFixedFields)} - onChange={(provider: ModelProvider) => getModelList(provider.plugin_id, provider.provider)} + onChange={(provider: string) => getModelList(provider)} /> ) } diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-list-item.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-list-item.tsx index a299d6a134..3fc73a62b2 100644 --- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-list-item.tsx +++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-list-item.tsx @@ -33,10 +33,10 @@ const ModelListItem = ({ model, provider, isConfigurable, onConfig, onModifyLoad const toggleModelEnablingStatus = useCallback(async (enabled: boolean) => { if (enabled) - await enableModel(`/workspaces/current/model-providers/${provider.plugin_id}/${provider.provider}/models/enable`, { model: model.model, model_type: model.model_type }) + await enableModel(`/workspaces/current/model-providers/${provider.provider}/models/enable`, { model: model.model, model_type: model.model_type }) else - await disableModel(`/workspaces/current/model-providers/${provider.plugin_id}/${provider.provider}/models/disable`, { model: model.model, model_type: model.model_type }) - }, [model.model, model.model_type, provider.plugin_id, provider.provider]) + await disableModel(`/workspaces/current/model-providers/${provider.provider}/models/disable`, { model: model.model, model_type: model.model_type }) + }, [model.model, model.model_type, provider.provider]) const { run: debouncedToggleModelEnablingStatus } = useDebounceFn(toggleModelEnablingStatus, { wait: 500 }) diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-list.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-list.tsx index 3b6a4ccbe5..5e70a0def1 100644 --- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-list.tsx +++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-list.tsx @@ -23,7 +23,7 @@ type ModelListProps = { models: ModelItem[] onCollapse: () => void onConfig: (currentCustomConfigurationModelFixedFields?: CustomConfigurationModelFixedFields) => void - onChange?: (provider: ModelProvider) => void + onChange?: (provider: string) => void } const ModelList: FC = ({ provider, diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-modal.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-modal.tsx index a58d6e13e7..edbb4665e9 100644 --- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-modal.tsx +++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-modal.tsx @@ -19,7 +19,7 @@ export type ModelLoadBalancingModalProps = { model: ModelItem open?: boolean onClose?: () => void - onSave?: (provider: ModelProvider) => void + onSave?: (provider: string) => void } // model balancing config modal @@ -30,7 +30,7 @@ const ModelLoadBalancingModal = ({ provider, model, open = false, onClose, onSav const [loading, setLoading] = useState(false) const { data, mutate } = useSWR( - `/workspaces/current/model-providers/${provider.plugin_id}/${provider.provider}/models/credentials?model=${model.model}&model_type=${model.model_type}`, + `/workspaces/current/model-providers/${provider.provider}/models/credentials?model=${model.model}&model_type=${model.model_type}`, fetchModelLoadBalancingConfig, ) @@ -94,7 +94,7 @@ const ModelLoadBalancingModal = ({ provider, model, open = false, onClose, onSav if (res.result === 'success') { notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) mutate() - onSave?.(provider) + onSave?.(provider.provider) onClose?.() } } diff --git a/web/app/components/header/account-setting/model-provider-page/system-model-selector/index.tsx b/web/app/components/header/account-setting/model-provider-page/system-model-selector/index.tsx index d125bd99fb..2e1e6400d1 100644 --- a/web/app/components/header/account-setting/model-provider-page/system-model-selector/index.tsx +++ b/web/app/components/header/account-setting/model-provider-page/system-model-selector/index.tsx @@ -94,7 +94,6 @@ const SystemModel: FC = ({ model_settings: [ModelTypeEnum.textGeneration, ModelTypeEnum.textEmbedding, ModelTypeEnum.rerank, ModelTypeEnum.speech2text, ModelTypeEnum.tts].map((modelType) => { return { model_type: modelType, - plugin_id: getCurrentDefaultModelByModelType(modelType)?.plugin_id, provider: getCurrentDefaultModelByModelType(modelType)?.provider, model: getCurrentDefaultModelByModelType(modelType)?.model, } @@ -132,6 +131,7 @@ const SystemModel: FC = ({ > setOpen(v => !v)}> ) diff --git a/web/app/components/plugins/marketplace/search-box/index.tsx b/web/app/components/plugins/marketplace/search-box/index.tsx index 12682bd725..7ca9ce17e0 100644 --- a/web/app/components/plugins/marketplace/search-box/index.tsx +++ b/web/app/components/plugins/marketplace/search-box/index.tsx @@ -1,6 +1,5 @@ 'use client' import { RiCloseLine } from '@remixicon/react' -import { useMarketplaceContext } from '../context' import TagsFilter from './tags-filter' import ActionButton from '@/app/components/base/action-button' import cn from '@/utils/classnames' @@ -11,6 +10,8 @@ type SearchBoxProps = { inputClassName?: string tags: string[] onTagsChange: (tags: string[]) => void + size?: 'small' | 'large' + placeholder?: string } const SearchBox = ({ search, @@ -18,36 +19,39 @@ const SearchBox = ({ inputClassName, tags, onTagsChange, + size = 'small', + placeholder = 'Search tools...', }: SearchBoxProps) => { - const intersected = useMarketplaceContext(v => v.intersected) - const searchPluginText = useMarketplaceContext(v => v.searchPluginText) - const handleSearchPluginTextChange = useMarketplaceContext(v => v.handleSearchPluginTextChange) - return (
{ onSearchChange(e.target.value) }} + placeholder={placeholder} /> { - searchPluginText && ( - handleSearchPluginTextChange('')}> + search && ( + onSearchChange('')}> ) diff --git a/web/app/components/plugins/marketplace/search-box/search-box-wrapper.tsx b/web/app/components/plugins/marketplace/search-box/search-box-wrapper.tsx index 0758d7785b..a124d93eb4 100644 --- a/web/app/components/plugins/marketplace/search-box/search-box-wrapper.tsx +++ b/web/app/components/plugins/marketplace/search-box/search-box-wrapper.tsx @@ -12,11 +12,15 @@ const SearchBoxWrapper = () => { return ( ) } diff --git a/web/app/components/plugins/marketplace/search-box/tags-filter.tsx b/web/app/components/plugins/marketplace/search-box/tags-filter.tsx index 51746fddb4..5114765544 100644 --- a/web/app/components/plugins/marketplace/search-box/tags-filter.tsx +++ b/web/app/components/plugins/marketplace/search-box/tags-filter.tsx @@ -18,10 +18,12 @@ import Input from '@/app/components/base/input' type TagsFilterProps = { tags: string[] onTagsChange: (tags: string[]) => void + size: 'small' | 'large' } const TagsFilter = ({ tags, onTagsChange, + size, }: TagsFilterProps) => { const [open, setOpen] = useState(false) const [searchText, setSearchText] = useState('') @@ -56,7 +58,9 @@ const TagsFilter = ({ > setOpen(v => !v)}>
@@ -65,6 +69,8 @@ const TagsFilter = ({
{ !selectedTagsLength && 'All Tags' @@ -95,7 +101,7 @@ const TagsFilter = ({ }
- +
= ({ className, payload, - installed = true, }) => { - const { locale } = useContext(I18n) + const { t } = useTranslation() + const language = useGetLanguage() const { org, label } = payload return (
- - {/* Header */} -
- -
-
- - <RiVerifiedBadgeLine className="shrink-0 ml-0.5 w-4 h-4 text-text-accent" /> - </div> - <div className='mb-1 flex justify-between items-center h-4'> - <div className='flex items-center'> - <div className='text-text-tertiary system-xs-regular'>{org}</div> - <div className='mx-2 text-text-quaternary system-xs-regular'>·</div> - <DownloadCount downloadCount={payload.install_count || 0} /> - </div> + {/* Header */} + <div className="flex"> + <Icon src={payload.icon} /> + <div className="ml-3 w-0 grow"> + <div className="flex items-center h-5"> + <Title title={label[language]} /> + <RiVerifiedBadgeLine className="shrink-0 ml-0.5 w-4 h-4 text-text-accent" /> + </div> + <div className='mb-1 flex justify-between items-center h-4'> + <div className='flex items-center'> + <div className='text-text-tertiary system-xs-regular'>{org}</div> + <div className='mx-2 text-text-quaternary system-xs-regular'>·</div> + <DownloadCount downloadCount={payload.install_count || 0} /> </div> </div> </div> - <Description className='mt-3' text={payload.brief[locale]} descriptionLineRows={2}></Description> - <div className='mt-3 flex space-x-0.5'> - {['LLM', 'text embedding', 'speech2text'].map(tag => ( - <Badge key={tag} text={tag} /> - ))} - </div> - {!installed && ( - <div - className='hidden group-hover:flex items-center gap-2 absolute bottom-0 left-0 right-0 p-4 pt-8' - style={{ background: 'linear-gradient(0deg, #F9FAFB 60.27%, rgba(249, 250, 251, 0.00) 100%)' }} - > - <Button - className='flex-grow' - variant='primary' - > - Install - </Button> - <Button - className='flex-grow' - variant='secondary' - > - Details - <RiArrowRightUpLine className='w-4 h-4' /> - </Button> - </div> - )} - </Link> + </div> + <Description className='mt-3' text={payload.brief[language]} descriptionLineRows={2}></Description> + <div className='mt-3 flex space-x-0.5'> + {payload.tags.map(tag => ( + <Badge key={tag.name} text={tag.name} /> + ))} + </div> + <div + className='hidden group-hover:flex items-center gap-2 absolute bottom-0 left-0 right-0 p-4 pt-8 rounded-xl bg-gradient-to-tr from-[#f9fafb] to-[rgba(249,250,251,0)]' + > + <Button + className='flex-grow' + variant='primary' + > + {t('plugin.detailPanel.operation.install')} + </Button> + <Button + className='flex-grow' + variant='secondary' + > + <a href={`${MARKETPLACE_URL_PREFIX}/plugin/${payload.org}/${payload.name}`} target='_blank' className='flex items-center gap-0.5'> + {t('plugin.detailPanel.operation.detail')} + <RiArrowRightUpLine className='w-4 h-4' /> + </a> + </Button> + </div> </div> ) } diff --git a/web/app/components/plugins/types.ts b/web/app/components/plugins/types.ts index f3cfd7f93c..74ba3ecab2 100644 --- a/web/app/components/plugins/types.ts +++ b/web/app/components/plugins/types.ts @@ -103,6 +103,7 @@ export type Plugin = { type: PluginType org: string name: string + plugin_id: string version: string latest_version: string icon: string diff --git a/web/app/components/tools/marketplace/hooks.ts b/web/app/components/tools/marketplace/hooks.ts index 82f019ef14..d1558e7aaf 100644 --- a/web/app/components/tools/marketplace/hooks.ts +++ b/web/app/components/tools/marketplace/hooks.ts @@ -37,7 +37,7 @@ export const useMarketplace = (searchPluginText: string, filterPluginTags: strin } else { queryMarketplaceCollectionsAndPlugins() - setPlugins(undefined) + setPlugins([]) } }, [searchPluginText, filterPluginTags, queryPlugins, queryMarketplaceCollectionsAndPlugins, queryPluginsWithDebounced, setPlugins]) diff --git a/web/app/components/workflow/block-selector/all-tools.tsx b/web/app/components/workflow/block-selector/all-tools.tsx index db80492ace..2b93ed32e5 100644 --- a/web/app/components/workflow/block-selector/all-tools.tsx +++ b/web/app/components/workflow/block-selector/all-tools.tsx @@ -84,9 +84,12 @@ const AllTools = ({ </div> <ViewTypeSelect viewType={activeView} onChange={setActiveView} /> {supportAddCustomTool && ( - <ActionButton> - <RiAddLine className='w-4 h-4' /> - </ActionButton> + <div className='flex items-center'> + <div className='mr-1.5 w-px h-3.5 bg-divider-regular'></div> + <ActionButton className='bg-components-button-primary-bg hover:bg-components-button-primary-bg text-components-button-primary-text hover:text-components-button-primary-text'> + <RiAddLine className='w-4 h-4' /> + </ActionButton> + </div> )} </div> <div diff --git a/web/app/components/workflow/block-selector/market-place-plugin/list.tsx b/web/app/components/workflow/block-selector/market-place-plugin/list.tsx index 3da4e04af5..6c82bd5c0c 100644 --- a/web/app/components/workflow/block-selector/market-place-plugin/list.tsx +++ b/web/app/components/workflow/block-selector/market-place-plugin/list.tsx @@ -1,5 +1,5 @@ 'use client' -import React, { forwardRef, useImperativeHandle, useMemo, useRef } from 'react' +import React, { forwardRef, useEffect, useImperativeHandle, useMemo, useRef } from 'react' import { useTranslation } from 'react-i18next' import useStickyScroll, { ScrollPosition } from '../use-sticky-scroll' import Item from './item' @@ -30,7 +30,6 @@ const List = ({ wrapElemRef, nextToStickyELemRef, }) - const stickyClassName = useMemo(() => { switch (scrollPosition) { case ScrollPosition.aboveTheWrap: @@ -38,7 +37,7 @@ const List = ({ case ScrollPosition.showing: return 'bottom-0 pt-3 pb-1' case ScrollPosition.belowTheWrap: - return 'bottom-0 items-center rounded-b-xl border-t border-[0.5px] border-components-panel-border bg-components-panel-bg-blur shadow-lg cursor-pointer' + return 'bottom-0 items-center rounded-b-xl border-t border-[0.5px] border-components-panel-border bg-components-panel-bg-blur shadow-lg rounded-b-lg cursor-pointer' } }, [scrollPosition]) @@ -46,6 +45,11 @@ const List = ({ handleScroll, })) + useEffect(() => { + handleScroll() + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [list]) + const handleHeadClick = () => { if (scrollPosition === ScrollPosition.belowTheWrap) { nextToStickyELemRef.current?.scrollIntoView({ behavior: 'smooth', block: 'start' }) @@ -57,7 +61,7 @@ const List = ({ if (hasSearchText) { return ( <Link - className='sticky bottom-0 z-10 flex h-8 px-4 py-1 system-sm-medium items-center rounded-b-xl border-t border-[0.5px] border-components-panel-border bg-components-panel-bg-blur shadow-lg text-text-accent-light-mode-only cursor-pointer' + className='sticky bottom-0 z-10 flex h-8 px-4 py-1 system-sm-medium items-center border-t border-[0.5px] border-components-panel-border bg-components-panel-bg-blur rounded-b-lg shadow-lg text-text-accent-light-mode-only cursor-pointer' href={`${marketplaceUrlPrefix}/plugins`} target='_blank' > diff --git a/web/app/components/workflow/block-selector/tool-picker.tsx b/web/app/components/workflow/block-selector/tool-picker.tsx index db59d044d2..9cc9686f84 100644 --- a/web/app/components/workflow/block-selector/tool-picker.tsx +++ b/web/app/components/workflow/block-selector/tool-picker.tsx @@ -2,6 +2,15 @@ import type { FC } from 'react' import React from 'react' import { useEffect, useState } from 'react' +import { + PortalToFollowElem, + PortalToFollowElemContent, + PortalToFollowElemTrigger, +} from '@/app/components/base/portal-to-follow-elem' +import type { + OffsetOptions, + Placement, +} from '@floating-ui/react' import AllTools from '@/app/components/workflow/block-selector/all-tools' import type { ToolDefaultValue } from './types' import { @@ -10,16 +19,31 @@ import { fetchAllWorkflowTools, } from '@/service/tools' import type { BlockEnum, ToolWithProvider } from '@/app/components/workflow/types' +import SearchBox from '@/app/components/plugins/marketplace/search-box' +import { useTranslation } from 'react-i18next' type Props = { + disabled: boolean + trigger: React.ReactNode + placement?: Placement + offset?: OffsetOptions + isShow: boolean + onShowChange: (isShow: boolean) => void onSelect: (tool: ToolDefaultValue) => void supportAddCustomTool?: boolean } const ToolPicker: FC<Props> = ({ + disabled, + trigger, + placement = 'right-start', + offset = 0, + isShow, + onShowChange, onSelect, supportAddCustomTool, }) => { + const { t } = useTranslation() const [searchText, setSearchText] = useState('') const [buildInTools, setBuildInTools] = useState<ToolWithProvider[]>([]) @@ -37,23 +61,52 @@ const ToolPicker: FC<Props> = ({ })() }, []) + const handleTriggerClick = () => { + if (disabled) return + onShowChange(true) + } + const handleSelect = (_type: BlockEnum, tool?: ToolDefaultValue) => { onSelect(tool!) } return ( - <div className="relative mt-5 mx-auto w-[320px] bg-white"> - <input placeholder='search holder' value={searchText} onChange={e => setSearchText(e.target.value)} /> - <AllTools - className='mt-1' - searchText={searchText} - onSelect={handleSelect} - buildInTools={buildInTools} - customTools={customTools} - workflowTools={workflowTools} - supportAddCustomTool={supportAddCustomTool} - /> - </div> + <PortalToFollowElem + placement={placement} + offset={offset} + open={isShow} + onOpenChange={onShowChange} + > + <PortalToFollowElemTrigger + onClick={handleTriggerClick} + > + {trigger} + </PortalToFollowElemTrigger> + + <PortalToFollowElemContent className='z-[1000]'> + <div className="relative w-[320px] min-h-20 rounded-xl bg-components-panel-bg-blur border-[0.5px] border-components-panel-border shadow-lg"> + <div className='p-2 pb-1'> + <SearchBox + search={searchText} + onSearchChange={setSearchText} + tags={[]} + onTagsChange={() => { }} + size='small' + placeholder={t('plugin.searchTools')!} + /> + </div> + <AllTools + className='mt-1' + searchText={searchText} + onSelect={handleSelect} + buildInTools={buildInTools} + customTools={customTools} + workflowTools={workflowTools} + supportAddCustomTool={supportAddCustomTool} + /> + </div> + </PortalToFollowElemContent> + </PortalToFollowElem> ) } diff --git a/web/app/components/workflow/nodes/llm/panel.tsx b/web/app/components/workflow/nodes/llm/panel.tsx index 038522df46..76607b29b1 100644 --- a/web/app/components/workflow/nodes/llm/panel.tsx +++ b/web/app/components/workflow/nodes/llm/panel.tsx @@ -132,7 +132,6 @@ const Panel: FC<NodePanelProps<LLMNodeType>> = ({ isInWorkflow isAdvancedMode={true} mode={model?.mode} - pluginId={model?.plugin_id} provider={model?.provider} completionParams={model?.completion_params} modelId={model?.name} diff --git a/web/app/components/workflow/nodes/llm/use-config.ts b/web/app/components/workflow/nodes/llm/use-config.ts index 7715383020..33742b0726 100644 --- a/web/app/components/workflow/nodes/llm/use-config.ts +++ b/web/app/components/workflow/nodes/llm/use-config.ts @@ -123,7 +123,7 @@ const useConfig = (id: string, payload: LLMNodeType) => { }, }) - const handleModelChanged = useCallback((model: { provider: string; modelId: string; pluginId: string; mode?: string }) => { + const handleModelChanged = useCallback((model: { provider: string; modelId: string; mode?: string }) => { const newInputs = produce(inputRef.current, (draft) => { draft.model.provider = model.provider draft.model.name = model.modelId @@ -139,7 +139,6 @@ const useConfig = (id: string, payload: LLMNodeType) => { useEffect(() => { if (currentProvider?.provider && currentModel?.model && !model.provider) { handleModelChanged({ - pluginId: currentProvider?.plugin_id, provider: currentProvider?.provider, modelId: currentModel?.model, mode: currentModel?.model_properties?.mode as string, diff --git a/web/app/components/workflow/nodes/parameter-extractor/panel.tsx b/web/app/components/workflow/nodes/parameter-extractor/panel.tsx index edadc2e4ba..e9d3856c71 100644 --- a/web/app/components/workflow/nodes/parameter-extractor/panel.tsx +++ b/web/app/components/workflow/nodes/parameter-extractor/panel.tsx @@ -77,7 +77,6 @@ const Panel: FC<NodePanelProps<ParameterExtractorNodeType>> = ({ isInWorkflow isAdvancedMode={true} mode={model?.mode} - pluginId={model?.plugin_id} provider={model?.provider} completionParams={model?.completion_params} modelId={model?.name} diff --git a/web/app/components/workflow/nodes/question-classifier/panel.tsx b/web/app/components/workflow/nodes/question-classifier/panel.tsx index 4b2866204b..523ec50019 100644 --- a/web/app/components/workflow/nodes/question-classifier/panel.tsx +++ b/web/app/components/workflow/nodes/question-classifier/panel.tsx @@ -65,7 +65,6 @@ const Panel: FC<NodePanelProps<QuestionClassifierNodeType>> = ({ isInWorkflow isAdvancedMode={true} mode={model?.mode} - pluginId={model?.plugin_id} provider={model?.provider} completionParams={model.completion_params} modelId={model.name} diff --git a/web/app/components/workflow/nodes/question-classifier/types.ts b/web/app/components/workflow/nodes/question-classifier/types.ts index ddc16b4501..ca102b083e 100644 --- a/web/app/components/workflow/nodes/question-classifier/types.ts +++ b/web/app/components/workflow/nodes/question-classifier/types.ts @@ -1,6 +1,6 @@ import type { CommonNodeType, Memory, ModelConfig, ValueSelector, VisionSetting } from '@/app/components/workflow/types' -export type Topic = { +export interface Topic { id: string name: string } diff --git a/web/app/components/workflow/types.ts b/web/app/components/workflow/types.ts index ef26d9465f..811ec0d70c 100644 --- a/web/app/components/workflow/types.ts +++ b/web/app/components/workflow/types.ts @@ -37,7 +37,7 @@ export enum ControlMode { Hand = 'hand', } -export type Branch = { +export interface Branch { id: string name: string } @@ -68,7 +68,7 @@ export type CommonNodeType<T = {}> = { height?: number } & T & Partial<Pick<ToolDefaultValue, 'provider_id' | 'provider_type' | 'provider_name' | 'tool_name'>> -export type CommonEdgeType = { +export interface CommonEdgeType { _hovering?: boolean _connectedNodeIsHovering?: boolean _connectedNodeIsSelected?: boolean @@ -82,14 +82,14 @@ export type CommonEdgeType = { export type Node<T = {}> = ReactFlowNode<CommonNodeType<T>> export type SelectedNode = Pick<Node, 'id' | 'data'> -export type NodeProps<T = unknown> = { id: string; data: CommonNodeType<T> } -export type NodePanelProps<T> = { +export interface NodeProps<T = unknown> { id: string; data: CommonNodeType<T> } +export interface NodePanelProps<T> { id: string data: CommonNodeType<T> } export type Edge = ReactFlowEdge<CommonEdgeType> -export type WorkflowDataUpdater = { +export interface WorkflowDataUpdater { nodes: Node[] edges: Edge[] viewport: Viewport @@ -97,7 +97,7 @@ export type WorkflowDataUpdater = { export type ValueSelector = string[] // [nodeId, key | obj key path] -export type Variable = { +export interface Variable { variable: string label?: string | { nodeType: BlockEnum @@ -112,14 +112,14 @@ export type Variable = { isParagraph?: boolean } -export type EnvironmentVariable = { +export interface EnvironmentVariable { id: string name: string value: any value_type: 'string' | 'number' | 'secret' } -export type ConversationVariable = { +export interface ConversationVariable { id: string name: string value_type: ChatVarType @@ -127,13 +127,13 @@ export type ConversationVariable = { description: string } -export type GlobalVariable = { +export interface GlobalVariable { name: string value_type: 'string' | 'number' description: string } -export type VariableWithValue = { +export interface VariableWithValue { key: string value: string } @@ -169,8 +169,7 @@ export type InputVar = { value_selector?: ValueSelector } & Partial<UploadFileSetting> -export type ModelConfig = { - plugin_id: string +export interface ModelConfig { provider: string name: string mode: string @@ -188,7 +187,7 @@ export enum EditionType { jinja2 = 'jinja2', } -export type PromptItem = { +export interface PromptItem { id?: string role?: PromptRole text: string @@ -201,12 +200,12 @@ export enum MemoryRole { assistant = 'assistant', } -export type RolePrefix = { +export interface RolePrefix { user: string assistant: string } -export type Memory = { +export interface Memory { role_prefix?: RolePrefix window: { enabled: boolean @@ -230,7 +229,7 @@ export enum VarType { any = 'any', } -export type Var = { +export interface Var { variable: string type: VarType children?: Var[] // if type is obj, has the children struct @@ -241,21 +240,21 @@ export type Var = { des?: string } -export type NodeOutPutVar = { +export interface NodeOutPutVar { nodeId: string title: string vars: Var[] isStartNode?: boolean } -export type Block = { +export interface Block { classification?: string type: BlockEnum title: string description?: string } -export type NodeDefault<T> = { +export interface NodeDefault<T> { defaultValue: Partial<T> getAvailablePrevNodes: (isChatMode: boolean) => BlockEnum[] getAvailableNextNodes: (isChatMode: boolean) => BlockEnum[] @@ -295,19 +294,19 @@ export type OnNodeAdd = ( } ) => void -export type CheckValidRes = { +export interface CheckValidRes { isValid: boolean errorMessage?: string } -export type RunFile = { +export interface RunFile { type: string transfer_method: TransferMethod[] url?: string upload_file_id?: string } -export type WorkflowRunningData = { +export interface WorkflowRunningData { task_id?: string message_id?: string conversation_id?: string @@ -332,7 +331,7 @@ export type WorkflowRunningData = { tracing?: NodeTracing[] } -export type HistoryWorkflowData = { +export interface HistoryWorkflowData { id: string sequence_number: number status: string @@ -344,7 +343,7 @@ export enum ChangeType { remove = 'remove', } -export type MoreInfo = { +export interface MoreInfo { type: ChangeType payload?: { beforeKey: string @@ -364,7 +363,7 @@ export enum SupportUploadFileTypes { custom = 'custom', } -export type UploadFileSetting = { +export interface UploadFileSetting { allowed_file_upload_methods: TransferMethod[] allowed_file_types: SupportUploadFileTypes[] allowed_file_extensions?: string[] @@ -372,7 +371,7 @@ export type UploadFileSetting = { number_limits?: number } -export type VisionSetting = { +export interface VisionSetting { variable_selector: ValueSelector detail: Resolution } diff --git a/web/context/modal-context.tsx b/web/context/modal-context.tsx index c8383ae336..60d53f1e98 100644 --- a/web/context/modal-context.tsx +++ b/web/context/modal-context.tsx @@ -32,7 +32,7 @@ import OpeningSettingModal from '@/app/components/base/features/new-feature-pane import type { OpeningStatement } from '@/app/components/base/features/types' import type { InputVar } from '@/app/components/workflow/types' -export type ModalState<T> = { +export interface ModalState<T> { payload: T onCancelCallback?: () => void onSaveCallback?: (newPayload: T) => void @@ -43,7 +43,7 @@ export type ModalState<T> = { datasetBindings?: { id: string; name: string }[] } -export type ModelModalType = { +export interface ModelModalType { currentProvider: ModelProvider currentConfigurationMethod: ConfigurationMethodEnum currentCustomConfigurationModelFixedFields?: CustomConfigurationModelFixedFields @@ -52,7 +52,7 @@ export type LoadBalancingEntryModalType = ModelModalType & { entry?: ModelLoadBalancingConfigEntry index?: number } -export type ModalContextState = { +export interface ModalContextState { setShowAccountSettingModal: Dispatch<SetStateAction<ModalState<string> | null>> setShowApiBasedExtensionModal: Dispatch<SetStateAction<ModalState<ApiBasedExtension> | null>> setShowModerationSettingModal: Dispatch<SetStateAction<ModalState<ModerationConfig> | null>> @@ -90,7 +90,7 @@ export const useModalContext = () => useContext(ModalContext) export const useModalContextSelector = <T,>(selector: (state: ModalContextState) => T): T => useContextSelector(ModalContext, selector) -type ModalContextProviderProps = { +interface ModalContextProviderProps { children: React.ReactNode } export const ModalContextProvider = ({ diff --git a/web/i18n/en-US/plugin.ts b/web/i18n/en-US/plugin.ts index dc615d3a94..d9897445bf 100644 --- a/web/i18n/en-US/plugin.ts +++ b/web/i18n/en-US/plugin.ts @@ -4,6 +4,7 @@ const translation = { searchInMarketplace: 'Search in Marketplace', fromMarketplace: 'From Marketplace', endpointsEnabled: '{{num}} sets of endpoints enabled', + searchTools: 'Search tools...', detailPanel: { categoryTip: { marketplace: 'Installed from Marketplace', @@ -13,7 +14,7 @@ const translation = { }, operation: { install: 'Install', - detail: 'Detail', + detail: 'Details', update: 'Update', info: 'Plugin Info', checkUpdate: 'Check Update', diff --git a/web/i18n/zh-Hans/plugin.ts b/web/i18n/zh-Hans/plugin.ts index a8b8b2dafa..5ced92c19e 100644 --- a/web/i18n/zh-Hans/plugin.ts +++ b/web/i18n/zh-Hans/plugin.ts @@ -4,6 +4,7 @@ const translation = { searchInMarketplace: '在 Marketplace 中搜索', fromMarketplace: '来自市场', endpointsEnabled: '{{num}} 组端点已启用', + searchTools: '搜索工具...', detailPanel: { categoryTip: { marketplace: '从 Marketplace 安装', diff --git a/web/models/debug.ts b/web/models/debug.ts index fe85544fa7..301248b234 100644 --- a/web/models/debug.ts +++ b/web/models/debug.ts @@ -10,25 +10,25 @@ export enum PromptMode { advanced = 'advanced', } -export type PromptItem = { +export interface PromptItem { role?: PromptRole text: string } -export type ChatPromptConfig = { +export interface ChatPromptConfig { prompt: PromptItem[] } -export type ConversationHistoriesRole = { +export interface ConversationHistoriesRole { user_prefix: string assistant_prefix: string } -export type CompletionPromptConfig = { +export interface CompletionPromptConfig { prompt: PromptItem conversation_histories_role: ConversationHistoriesRole } -export type BlockStatus = { +export interface BlockStatus { context: boolean history: boolean query: boolean @@ -40,7 +40,7 @@ export enum PromptRole { assistant = 'assistant', } -export type PromptVariable = { +export interface PromptVariable { key: string name: string type: string // "string" | "number" | "select", @@ -55,7 +55,7 @@ export type PromptVariable = { icon_background?: string } -export type CompletionParams = { +export interface CompletionParams { max_tokens: number temperature: number top_p: number @@ -66,12 +66,12 @@ export type CompletionParams = { export type ModelId = 'gpt-3.5-turbo' | 'text-davinci-003' -export type PromptConfig = { +export interface PromptConfig { prompt_template: string prompt_variables: PromptVariable[] } -export type MoreLikeThisConfig = { +export interface MoreLikeThisConfig { enabled: boolean } @@ -79,7 +79,7 @@ export type SuggestedQuestionsAfterAnswerConfig = MoreLikeThisConfig export type SpeechToTextConfig = MoreLikeThisConfig -export type TextToSpeechConfig = { +export interface TextToSpeechConfig { enabled: boolean voice?: string language?: string @@ -88,18 +88,17 @@ export type TextToSpeechConfig = { export type CitationConfig = MoreLikeThisConfig -export type AnnotationReplyConfig = { +export interface AnnotationReplyConfig { id: string enabled: boolean score_threshold: number embedding_model: { - plugin_id: string embedding_provider_name: string embedding_model_name: string } } -export type ModerationContentConfig = { +export interface ModerationContentConfig { enabled: boolean preset_response?: string } @@ -114,15 +113,14 @@ export type ModerationConfig = MoreLikeThisConfig & { } export type RetrieverResourceConfig = MoreLikeThisConfig -export type AgentConfig = { +export interface AgentConfig { enabled: boolean strategy: AgentStrategy max_iteration: number tools: ToolItem[] } // frontend use. Not the same as backend -export type ModelConfig = { - plugin_id: string +export interface ModelConfig { provider: string // LLM Provider: for example "OPENAI" model_id: string mode: ModelModeType @@ -140,17 +138,16 @@ export type ModelConfig = { dataSets: any[] agentConfig: AgentConfig } -export type DatasetConfigItem = { +export interface DatasetConfigItem { enable: boolean value: number } -export type DatasetConfigs = { +export interface DatasetConfigs { retrieval_model: RETRIEVE_TYPE reranking_model: { reranking_provider_name: string reranking_model_name: string - reranking_plugin_id: string } top_k: number score_threshold_enabled: boolean @@ -175,39 +172,39 @@ export type DatasetConfigs = { reranking_enable?: boolean } -export type DebugRequestBody = { +export interface DebugRequestBody { inputs: Inputs query: string completion_params: CompletionParams model_config: ModelConfig } -export type DebugResponse = { +export interface DebugResponse { id: string answer: string created_at: string } -export type DebugResponseStream = { +export interface DebugResponseStream { id: string data: string created_at: string } -export type FeedBackRequestBody = { +export interface FeedBackRequestBody { message_id: string rating: 'like' | 'dislike' content?: string from_source: 'api' | 'log' } -export type FeedBackResponse = { +export interface FeedBackResponse { message_id: string rating: 'like' | 'dislike' } // Log session list -export type LogSessionListQuery = { +export interface LogSessionListQuery { keyword?: string start?: string // format datetime(YYYY-mm-dd HH:ii) end?: string // format datetime(YYYY-mm-dd HH:ii) @@ -215,7 +212,7 @@ export type LogSessionListQuery = { limit: number // default 20. 1-100 } -export type LogSessionListResponse = { +export interface LogSessionListResponse { data: { id: string conversation_id: string @@ -229,7 +226,7 @@ export type LogSessionListResponse = { } // log session detail and debug -export type LogSessionDetailResponse = { +export interface LogSessionDetailResponse { id: string conversation_id: string model_provider: string @@ -243,7 +240,7 @@ export type LogSessionDetailResponse = { from_source: 'api' | 'log' } -export type SavedMessage = { +export interface SavedMessage { id: string answer: string } diff --git a/web/models/log.ts b/web/models/log.ts index 99467c3f67..dc557bfe21 100644 --- a/web/models/log.ts +++ b/web/models/log.ts @@ -107,7 +107,6 @@ export type MessageContent = { agent_thoughts: any[] // TODO workflow_run_id: string parent_message_id: string | null - plugin_id: string } export type CompletionConversationGeneralDetail = { @@ -130,7 +129,6 @@ export type CompletionConversationGeneralDetail = { dislike: number } model_config: { - plugin_id: string provider: string model_id: string configs: Pick<ModelConfigDetail, 'prompt_template'> diff --git a/web/service/annotation.ts b/web/service/annotation.ts index 868f82bedc..5096a4f58a 100644 --- a/web/service/annotation.ts +++ b/web/service/annotation.ts @@ -13,9 +13,7 @@ export const updateAnnotationStatus = (appId: string, action: AnnotationEnableSt if (embeddingModel) { body = { ...body, - embedding_model_plugin_id: embeddingModel.plugin_id, - embedding_provider_name: embeddingModel.embedding_provider_name, - embedding_model_name: embeddingModel.embedding_model_name, + ...embeddingModel, } } diff --git a/web/service/debug.ts b/web/service/debug.ts index 887fde02c6..093cddfd62 100644 --- a/web/service/debug.ts +++ b/web/service/debug.ts @@ -3,13 +3,13 @@ import type { IOnCompleted, IOnData, IOnError, IOnFile, IOnMessageEnd, IOnMessag import type { ChatPromptConfig, CompletionPromptConfig } from '@/models/debug' import type { ModelModeType } from '@/types/app' import type { ModelParameterRule } from '@/app/components/header/account-setting/model-provider-page/declarations' -export type AutomaticRes = { +export interface AutomaticRes { prompt: string variables: string[] opening_statement: string error?: string } -export type CodeGenRes = { +export interface CodeGenRes { code: string language: string[] error?: string @@ -82,8 +82,8 @@ export const generateRuleCode = (body: Record<string, any>) => { }) } -export const fetchModelParams = (pluginID: string, providerName: string, modelId: string) => { - return get(`workspaces/current/model-providers/${pluginID}/${providerName}/models/parameter-rules`, { +export const fetchModelParams = (providerName: string, modelId: string) => { + return get(`workspaces/current/model-providers/${providerName}/models/parameter-rules`, { params: { model: modelId, },