Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

Fix type error (#27152)

GuanMu6217c96576e2
diff --git a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/tracing/config-popup.tsx b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/tracing/config-popup.tsx
index e4c3f60c12d..0ad02ad7f3f 100644
--- a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/tracing/config-popup.tsx
+++ b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/tracing/config-popup.tsx
@@ -73,7 +73,7 @@ const ConfigPopup: FC<PopupProps> = ({
}
}, [onChooseProvider])
- const handleConfigUpdated = useCallback((payload: ArizeConfig | PhoenixConfig | LangSmithConfig | LangFuseConfig | OpikConfig | WeaveConfig | AliyunConfig) => {
+ const handleConfigUpdated = useCallback((payload: ArizeConfig | PhoenixConfig | LangSmithConfig | LangFuseConfig | OpikConfig | WeaveConfig | AliyunConfig | TencentConfig) => {
onConfigUpdated(currentProvider!, payload)
hideConfigModal()
}, [currentProvider, hideConfigModal, onConfigUpdated])
diff --git a/web/app/components/base/auto-height-textarea/index.tsx b/web/app/components/base/auto-height-textarea/index.tsx
index da412a176dc..fb64bf9db4e 100644
--- a/web/app/components/base/auto-height-textarea/index.tsx
+++ b/web/app/components/base/auto-height-textarea/index.tsx
@@ -31,7 +31,7 @@ const AutoHeightTextarea = (
onKeyDown,
onKeyUp,
}: IProps & {
- ref: React.RefObject<unknown>;
+ ref?: React.RefObject<HTMLTextAreaElement>;
},
) => {
// eslint-disable-next-line react-hooks/rules-of-hooks
diff --git a/web/app/components/billing/type.ts b/web/app/components/billing/type.ts
index 7cc4d197556..72d46f1e708 100644
--- a/web/app/components/billing/type.ts
+++ b/web/app/components/billing/type.ts
@@ -10,7 +10,7 @@ export enum Priority {
topPriority = 'top-priority',
}
-export type BasicPlan = Plan.sandbox | Plan.professional | Plan.team
+export type BasicPlan = Plan.sandbox | Plan.professional | Plan.team | Plan.enterprise
export type PlanInfo = {
level: number
diff --git a/web/app/components/datasets/documents/detail/metadata/index.tsx b/web/app/components/datasets/documents/detail/metadata/index.tsx
index 88c359f8b2b..209c141dd59 100644
--- a/web/app/components/datasets/documents/detail/metadata/index.tsx
+++ b/web/app/components/datasets/documents/detail/metadata/index.tsx
@@ -57,36 +57,44 @@ export const FieldInfo: FC<IFieldInfoProps> = ({
const editAlignTop = showEdit && inputType === 'textarea'
const readAlignTop = !showEdit && textNeedWrap
+ const renderContent = () => {
+ if (!showEdit)
+ return displayedValue
+
+ if (inputType === 'select') {
+ return <SimpleSelect
+ onSelect={({ value }) => onUpdate?.(value as string)}
+ items={selectOptions}
+ defaultValue={value}
+ className={s.select}
+ wrapperClassName={s.selectWrapper}
+ placeholder={`${t('datasetDocuments.metadata.placeholder.select')}${label}`}
+ />
+ }
+
+ if (inputType === 'textarea') {
+ return <AutoHeightTextarea
+ onChange={e => onUpdate?.(e.target.value)}
+ value={value}
+ className={s.textArea}
+ placeholder={`${t('datasetDocuments.metadata.placeholder.add')}${label}`}
+ />
+ }
+
+ return <Input
+ onChange={e => onUpdate?.(e.target.value)}
+ value={value}
+ defaultValue={defaultValue}
+ placeholder={`${t('datasetDocuments.metadata.placeholder.add')}${label}`}
+ />
+ }
+
return (
<div className={cn('flex min-h-5 items-center gap-1 py-0.5 text-xs', editAlignTop && '!items-start', readAlignTop && '!items-start pt-1')}>
<div className={cn('w-[200px] shrink-0 overflow-hidden text-ellipsis whitespace-nowrap text-text-tertiary', editAlignTop && 'pt-1')}>{label}</div>
<div className="flex grow items-center gap-1 text-text-secondary">
{valueIcon}
- {!showEdit
- ? displayedValue
- : inputType === 'select'
- ? <SimpleSelect
- onSelect={({ value }) => onUpdate?.(value as string)}
- items={selectOptions}
- defaultValue={value}
- className={s.select}
- wrapperClassName={s.selectWrapper}
- placeholder={`${t('datasetDocuments.metadata.placeholder.select')}${label}`}
- />
- : inputType === 'textarea'
- ? <AutoHeightTextarea
- onChange={e => onUpdate?.(e.target.value)}
- value={value}
- className={s.textArea}
- placeholder={`${t('datasetDocuments.metadata.placeholder.add')}${label}`}
- />
- : <Input
- onChange={e => onUpdate?.(e.target.value)}
- value={value}
- defaultValue={defaultValue}
- placeholder={`${t('datasetDocuments.metadata.placeholder.add')}${label}`}
- />
- }
+ {renderContent()}
</div>
</div>
)
diff --git a/web/app/components/plugins/plugin-detail-panel/action-list.tsx b/web/app/components/plugins/plugin-detail-panel/action-list.tsx
index 040c728630c..a6a4544216a 100644
--- a/web/app/components/plugins/plugin-detail-panel/action-list.tsx
+++ b/web/app/components/plugins/plugin-detail-panel/action-list.tsx
@@ -15,15 +15,15 @@ const ActionList = ({
detail,
}: Props) => {
const { t } = useTranslation()
- const providerBriefInfo = detail.declaration.tool.identity
- const providerKey = `${detail.plugin_id}/${providerBriefInfo.name}`
+ const providerBriefInfo = detail.declaration?.tool?.identity
+ const providerKey = providerBriefInfo ? `${detail.plugin_id}/${providerBriefInfo.name}` : ''
const { data: collectionList = [] } = useAllToolProviders()
const provider = useMemo(() => {
return collectionList.find(collection => collection.name === providerKey)
}, [collectionList, providerKey])
const { data } = useBuiltinTools(providerKey)
- if (!data || !provider)
+ if (!providerKey || !data || !provider)
return null
return (
diff --git a/web/global.d.ts b/web/global.d.ts
index 20b84a5327e..c5488a6caeb 100644
--- a/web/global.d.ts
+++ b/web/global.d.ts
@@ -1,5 +1,6 @@
import './types/i18n'
import './types/jsx'
+import './types/mdx'
declare module 'lamejs';
declare module 'lamejs/src/js/MPEGMode';
@@ -7,9 +8,4 @@ declare module 'lamejs/src/js/Lame';
declare module 'lamejs/src/js/BitStream';
declare module 'react-18-input-autosize';
-declare module '*.mdx' {
- let MDXComponent: (props: any) => JSX.Element
- export default MDXComponent
-}
-
export {}
diff --git a/web/service/use-tools.ts b/web/service/use-tools.ts
index e9d3ac1c8d7..a881441cd5b 100644
--- a/web/service/use-tools.ts
+++ b/web/service/use-tools.ts
@@ -274,6 +274,7 @@ export const useInvalidateBuiltinProviderInfo = () => {
export const useBuiltinTools = (providerName: string) => {
return useQuery({
+ enabled: !!providerName,
queryKey: [NAME_SPACE, 'builtin-provider-tools', providerName],
queryFn: () => get<Tool[]>(`/workspaces/current/tool-provider/builtin/${providerName}/tools`),
})
diff --git a/web/types/mdx.d.ts b/web/types/mdx.d.ts
new file mode 100644
index 00000000000..fab7616911b
--- /dev/null
+++ b/web/types/mdx.d.ts
@@ -0,0 +1,4 @@
+declare module '*.mdx' {
+ const MDXComponent: (props?: Record<string, unknown>) => JSX.Element
+ export default MDXComponent
+}