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 (#27274)

GuanMuc61c2b0abdce
diff --git a/web/app/components/app/annotation/index.tsx b/web/app/components/app/annotation/index.tsx
index 264b1ac7274..bc63b85f6d1 100644
--- a/web/app/components/app/annotation/index.tsx
+++ b/web/app/components/app/annotation/index.tsx
@@ -53,7 +53,6 @@ const Annotation: FC<Props> = (props) => {
const [isShowViewModal, setIsShowViewModal] = useState(false)
const [selectedIds, setSelectedIds] = useState<string[]>([])
const debouncedQueryParams = useDebounce(queryParams, { wait: 500 })
- const [isBatchDeleting, setIsBatchDeleting] = useState(false)
const fetchAnnotationConfig = async () => {
const res = await doFetchAnnotationConfig(appDetail.id)
@@ -108,9 +107,6 @@ const Annotation: FC<Props> = (props) => {
}
const handleBatchDelete = async () => {
- if (isBatchDeleting)
- return
- setIsBatchDeleting(true)
try {
await delAnnotations(appDetail.id, selectedIds)
Toast.notify({ message: t('common.api.actionSuccess'), type: 'success' })
@@ -121,9 +117,6 @@ const Annotation: FC<Props> = (props) => {
catch (e: any) {
Toast.notify({ type: 'error', message: e.message || t('common.api.actionFailed') })
}
- finally {
- setIsBatchDeleting(false)
- }
}
const handleView = (item: AnnotationItem) => {
@@ -213,7 +206,6 @@ const Annotation: FC<Props> = (props) => {
onSelectedIdsChange={setSelectedIds}
onBatchDelete={handleBatchDelete}
onCancel={() => setSelectedIds([])}
- isBatchDeleting={isBatchDeleting}
/>
: <div className='flex h-full grow items-center justify-center'><EmptyElement /></div>
}
diff --git a/web/app/components/app/annotation/list.tsx b/web/app/components/app/annotation/list.tsx
index 6705ac57681..70ecedb8699 100644
--- a/web/app/components/app/annotation/list.tsx
+++ b/web/app/components/app/annotation/list.tsx
@@ -19,7 +19,6 @@ type Props = {
onSelectedIdsChange: (selectedIds: string[]) => void
onBatchDelete: () => Promise<void>
onCancel: () => void
- isBatchDeleting?: boolean
}
const List: FC<Props> = ({
@@ -30,7 +29,6 @@ const List: FC<Props> = ({
onSelectedIdsChange,
onBatchDelete,
onCancel,
- isBatchDeleting,
}) => {
const { t } = useTranslation()
const { formatTime } = useTimestamp()
@@ -142,7 +140,6 @@ const List: FC<Props> = ({
selectedIds={selectedIds}
onBatchDelete={onBatchDelete}
onCancel={onCancel}
- isBatchDeleting={isBatchDeleting}
/>
)}
</div>
diff --git a/web/app/components/app/configuration/config-prompt/advanced-prompt-input.tsx b/web/app/components/app/configuration/config-prompt/advanced-prompt-input.tsx
index 70e0334e98c..aa8d0f65caf 100644
--- a/web/app/components/app/configuration/config-prompt/advanced-prompt-input.tsx
+++ b/web/app/components/app/configuration/config-prompt/advanced-prompt-input.tsx
@@ -78,7 +78,9 @@ const AdvancedPromptInput: FC<Props> = ({
const handleOpenExternalDataToolModal = () => {
setShowExternalDataToolModal({
payload: {},
- onSaveCallback: (newExternalDataTool: ExternalDataTool) => {
+ onSaveCallback: (newExternalDataTool?: ExternalDataTool) => {
+ if (!newExternalDataTool)
+ return
eventEmitter?.emit({
type: ADD_EXTERNAL_DATA_TOOL,
payload: newExternalDataTool,
diff --git a/web/app/components/app/configuration/config-prompt/simple-prompt-input.tsx b/web/app/components/app/configuration/config-prompt/simple-prompt-input.tsx
index 169e8a14a2f..8634232b2b3 100644
--- a/web/app/components/app/configuration/config-prompt/simple-prompt-input.tsx
+++ b/web/app/components/app/configuration/config-prompt/simple-prompt-input.tsx
@@ -76,7 +76,9 @@ const Prompt: FC<ISimplePromptInput> = ({
const handleOpenExternalDataToolModal = () => {
setShowExternalDataToolModal({
payload: {},
- onSaveCallback: (newExternalDataTool: ExternalDataTool) => {
+ onSaveCallback: (newExternalDataTool?: ExternalDataTool) => {
+ if (!newExternalDataTool)
+ return
eventEmitter?.emit({
type: ADD_EXTERNAL_DATA_TOOL,
payload: newExternalDataTool,
diff --git a/web/app/components/app/configuration/config-var/config-modal/index.tsx b/web/app/components/app/configuration/config-var/config-modal/index.tsx
index de7d2c9eac6..3f32c9b0c78 100644
--- a/web/app/components/app/configuration/config-var/config-modal/index.tsx
+++ b/web/app/components/app/configuration/config-var/config-modal/index.tsx
@@ -320,7 +320,7 @@ const ConfigModal: FC<IConfigModalProps> = ({
{type === InputVarType.paragraph && (
<Field title={t('appDebug.variableConfig.defaultValue')}>
<Textarea
- value={tempPayload.default || ''}
+ value={String(tempPayload.default ?? '')}
onChange={e => handlePayloadChange('default')(e.target.value || undefined)}
placeholder={t('appDebug.variableConfig.inputPlaceholder')!}
/>
diff --git a/web/app/components/app/configuration/config-var/index.tsx b/web/app/components/app/configuration/config-var/index.tsx
index 67264982949..0e453d51716 100644
--- a/web/app/components/app/configuration/config-var/index.tsx
+++ b/web/app/components/app/configuration/config-var/index.tsx
@@ -121,7 +121,9 @@ const ConfigVar: FC<IConfigVarProps> = ({ promptVariables, readonly, onPromptVar
icon,
icon_background,
},
- onSaveCallback: (newExternalDataTool: ExternalDataTool) => {
+ onSaveCallback: (newExternalDataTool?: ExternalDataTool) => {
+ if (!newExternalDataTool)
+ return
const newPromptVariables = oldPromptVariables.map((item, i) => {
if (i === index) {
return {
diff --git a/web/app/components/app/configuration/config/agent/prompt-editor.tsx b/web/app/components/app/configuration/config/agent/prompt-editor.tsx
index 98b23e53798..71a9304d0c7 100644
--- a/web/app/components/app/configuration/config/agent/prompt-editor.tsx
+++ b/web/app/components/app/configuration/config/agent/prompt-editor.tsx
@@ -51,7 +51,9 @@ const Editor: FC<Props> = ({
const handleOpenExternalDataToolModal = () => {
setShowExternalDataToolModal({
payload: {},
- onSaveCallback: (newExternalDataTool: ExternalDataTool) => {
+ onSaveCallback: (newExternalDataTool?: ExternalDataTool) => {
+ if (!newExternalDataTool)
+ return
setExternalDataToolsConfig([...externalDataToolsConfig, newExternalDataTool])
},
onValidateBeforeSaveCallback: (newExternalDataTool: ExternalDataTool) => {
diff --git a/web/app/components/app/configuration/debug/index.tsx b/web/app/components/app/configuration/debug/index.tsx
index ac26b82525b..23e1fdf9c4a 100644
--- a/web/app/components/app/configuration/debug/index.tsx
+++ b/web/app/components/app/configuration/debug/index.tsx
@@ -109,7 +109,7 @@ const Debug: FC<IDebug> = ({
setIsShowFormattingChangeConfirm(true)
}, [formattingChanged])
- const debugWithSingleModelRef = React.useRef<DebugWithSingleModelRefType | null>(null)
+ const debugWithSingleModelRef = React.useRef<DebugWithSingleModelRefType>(null!)
const handleClearConversation = () => {
debugWithSingleModelRef.current?.handleRestart()
}
diff --git a/web/app/components/app/configuration/tools/index.tsx b/web/app/components/app/configuration/tools/index.tsx
index ba586bb20df..8668f6166d1 100644
--- a/web/app/components/app/configuration/tools/index.tsx
+++ b/web/app/components/app/configuration/tools/index.tsx
@@ -76,7 +76,11 @@ const Tools = () => {
const handleOpenExternalDataToolModal = (payload: ExternalDataTool, index: number) => {
setShowExternalDataToolModal({
payload,
- onSaveCallback: (externalDataTool: ExternalDataTool) => handleSaveExternalDataToolModal(externalDataTool, index),
+ onSaveCallback: (externalDataTool?: ExternalDataTool) => {
+ if (!externalDataTool)
+ return
+ handleSaveExternalDataToolModal(externalDataTool, index)
+ },
onValidateBeforeSaveCallback: (newExternalDataTool: ExternalDataTool) => handleValidateBeforeSaveExternalDataToolModal(newExternalDataTool, index),
})
}
diff --git a/web/app/components/app/create-from-dsl-modal/index.tsx b/web/app/components/app/create-from-dsl-modal/index.tsx
index 8faafe05a87..e1a556a7091 100644
--- a/web/app/components/app/create-from-dsl-modal/index.tsx
+++ b/web/app/components/app/create-from-dsl-modal/index.tsx
@@ -84,7 +84,7 @@ const CreateFromDSLModal = ({ show, onSuccess, onClose, activeTab = CreateFromDS
handleFile(droppedFile)
}, [droppedFile])
- const onCreate: MouseEventHandler = async () => {
+ const onCreate = async (_e?: React.MouseEvent) => {
if (currentTab === CreateFromDSLModalTab.FROM_FILE && !currentFile)
return
if (currentTab === CreateFromDSLModalTab.FROM_URL && !dslUrlValue)
@@ -154,7 +154,7 @@ const CreateFromDSLModal = ({ show, onSuccess, onClose, activeTab = CreateFromDS
useKeyPress(['meta.enter', 'ctrl.enter'], () => {
if (show && !isAppsFull && ((currentTab === CreateFromDSLModalTab.FROM_FILE && currentFile) || (currentTab === CreateFromDSLModalTab.FROM_URL && dslUrlValue)))
- handleCreateApp()
+ handleCreateApp(undefined)
})
useKeyPress('esc', () => {
diff --git a/web/app/components/base/confirm/index.tsx b/web/app/components/base/confirm/index.tsx
index 8cb1c8bf8b5..9771c0e43c9 100644
--- a/web/app/components/base/confirm/index.tsx
+++ b/web/app/components/base/confirm/index.tsx
@@ -6,7 +6,7 @@ import Button from '../button'
export type IConfirm = {
className?: string
isShow: boolean
- type?: 'info' | 'warning'
+ type?: 'info' | 'warning' | 'danger'
title: string
content?: React.ReactNode
confirmText?: string | null
diff --git a/web/app/components/tools/labels/constant.ts b/web/app/components/tools/labels/constant.ts
index e7d3503e734..ae166889605 100644
--- a/web/app/components/tools/labels/constant.ts
+++ b/web/app/components/tools/labels/constant.ts
@@ -2,6 +2,6 @@ import type { TypeWithI18N } from '@/app/components/header/account-setting/model
export type Label = {
name: string
- label: TypeWithI18N
- icon: string
+ label: TypeWithI18N | string
+ icon?: string
}
diff --git a/web/app/components/tools/types.ts b/web/app/components/tools/types.ts
index 93b15b05336..623a7b6d8aa 100644
--- a/web/app/components/tools/types.ts
+++ b/web/app/components/tools/types.ts
@@ -7,6 +7,7 @@ export enum LOC {
export enum AuthType {
none = 'none',
+ apiKey = 'api_key', // backward compatibility
apiKeyHeader = 'api_key_header',
apiKeyQuery = 'api_key_query',
}
diff --git a/web/models/app.ts b/web/models/app.ts
index 26e6cba85b0..454cc5d1e84 100644
--- a/web/models/app.ts
+++ b/web/models/app.ts
@@ -1,4 +1,4 @@
-import type { AliyunConfig, ArizeConfig, LangFuseConfig, LangSmithConfig, OpikConfig, PhoenixConfig, TracingProvider, WeaveConfig } from '@/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/tracing/type'
+import type { AliyunConfig, ArizeConfig, LangFuseConfig, LangSmithConfig, OpikConfig, PhoenixConfig, TencentConfig, TracingProvider, WeaveConfig } from '@/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/tracing/type'
import type { App, AppMode, AppTemplate, SiteConfig } from '@/types/app'
import type { Dependency } from '@/app/components/plugins/types'
@@ -109,5 +109,5 @@ export type TracingStatus = {
export type TracingConfig = {
tracing_provider: TracingProvider
- tracing_config: ArizeConfig | PhoenixConfig | LangSmithConfig | LangFuseConfig | OpikConfig | WeaveConfig | AliyunConfig
+ tracing_config: ArizeConfig | PhoenixConfig | LangSmithConfig | LangFuseConfig | OpikConfig | WeaveConfig | AliyunConfig | TencentConfig
}
diff --git a/web/package.json b/web/package.json
index 6487108bfc3..b2dc48ba555 100644
--- a/web/package.json
+++ b/web/package.json
@@ -222,6 +222,8 @@
},
"pnpm": {
"overrides": {
+ "lexical": "0.37.0",
+ "@lexical/*": "0.37.0",
"@eslint/plugin-kit@<0.3.4": "0.3.4",
"brace-expansion@<2.0.2": "2.0.2",
"devalue@<5.3.2": "5.3.2",
diff --git a/web/pnpm-lock.yaml b/web/pnpm-lock.yaml
index 14f5c06a0c1..3eb396ce423 100644
--- a/web/pnpm-lock.yaml
+++ b/web/pnpm-lock.yaml
@@ -15,6 +15,8 @@ overrides:
vite: ~6.2
prismjs: ~1.30
brace-expansion: ~2.0
+ lexical: 0.37.0
+ '@lexical/*': 0.37.0
'@eslint/plugin-kit@<0.3.4': 0.3.4
brace-expansion@<2.0.2: 2.0.2
devalue@<5.3.2: 5.3.2
@@ -199,8 +201,8 @@ importers:
specifier: ^1.2.1
version: 1.2.1
lexical:
- specifier: ^0.36.2
- version: 0.36.2
+ specifier: 0.37.0
+ version: 0.37.0
line-clamp:
specifier: ^1.0.0
version: 1.0.0
@@ -6241,9 +6243,6 @@ packages:
resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==}
engines: {node: '>= 0.8.0'}
- resolution: {integrity: sha512-gIDJCmSAhtxD7h95WK17Nz19wCZu92Zn0p1/R45X01S/KAsLCwEtVJ2fTvIJNFTyx3QNJTuGcm5mYgRMUwq8rg==}
-
resolution: {integrity: sha512-r5VJR2TioQPAsZATfktnJFrGIiy6gjQN8b/+0a2u1d7/QTH7lhbB7byhGSvcq1iaa1TV/xcf/pFV55a5V5hTDQ==}
@@ -10538,7 +10537,7 @@ snapshots:
'@lexical/list': 0.36.2
'@lexical/selection': 0.36.2
'@lexical/utils': 0.36.2
- lexical: 0.36.2
+ lexical: 0.37.0
'@lexical/[email protected]':
dependencies:
@@ -10551,7 +10550,7 @@ snapshots:
'@lexical/[email protected]':
dependencies:
'@lexical/utils': 0.36.2
- lexical: 0.36.2
+ lexical: 0.37.0
prismjs: 1.30.0
@@ -10561,20 +10560,20 @@ snapshots:
'@lexical/mark': 0.36.2
'@lexical/table': 0.36.2
'@lexical/utils': 0.36.2
- lexical: 0.36.2
+ lexical: 0.37.0
react: 19.1.1
react-dom: 19.1.1([email protected])
'@lexical/[email protected]':
dependencies:
'@lexical/extension': 0.36.2
- lexical: 0.36.2
+ lexical: 0.37.0
'@lexical/[email protected]':
dependencies:
'@lexical/utils': 0.36.2
'@preact/signals-core': 1.12.1
- lexical: 0.36.2
+ lexical: 0.37.0
'@lexical/[email protected]':
dependencies:
@@ -10586,19 +10585,19 @@ snapshots:
dependencies:
'@lexical/text': 0.36.2
'@lexical/utils': 0.36.2
- lexical: 0.36.2
+ lexical: 0.37.0
'@lexical/[email protected]':
dependencies:
'@lexical/extension': 0.36.2
'@lexical/utils': 0.36.2
- lexical: 0.36.2
+ lexical: 0.37.0
'@lexical/[email protected]':
dependencies:
'@lexical/selection': 0.36.2
'@lexical/utils': 0.36.2
- lexical: 0.36.2
+ lexical: 0.37.0
'@lexical/[email protected]':
dependencies:
@@ -10610,14 +10609,14 @@ snapshots:
dependencies:
'@lexical/extension': 0.36.2
'@lexical/utils': 0.36.2
- lexical: 0.36.2
+ lexical: 0.37.0
'@lexical/[email protected]':
dependencies:
'@lexical/extension': 0.36.2
'@lexical/selection': 0.36.2
'@lexical/utils': 0.36.2
- lexical: 0.36.2
+ lexical: 0.37.0
'@lexical/[email protected]':
dependencies:
@@ -10629,7 +10628,7 @@ snapshots:
'@lexical/[email protected]':
dependencies:
'@lexical/utils': 0.36.2
- lexical: 0.36.2
+ lexical: 0.37.0
'@lexical/[email protected]':
dependencies:
@@ -10639,15 +10638,15 @@ snapshots:
'@lexical/rich-text': 0.36.2
'@lexical/text': 0.36.2
'@lexical/utils': 0.36.2
- lexical: 0.36.2
+ lexical: 0.37.0
'@lexical/[email protected]':
dependencies:
- lexical: 0.36.2
+ lexical: 0.37.0
'@lexical/[email protected]':
dependencies:
- lexical: 0.36.2
+ lexical: 0.37.0
'@lexical/[email protected]':
dependencies:
@@ -10655,7 +10654,7 @@ snapshots:
'@lexical/dragon': 0.36.2
'@lexical/selection': 0.36.2
'@lexical/utils': 0.36.2
- lexical: 0.36.2
+ lexical: 0.37.0
dependencies:
@@ -10676,7 +10675,7 @@ snapshots:
'@lexical/text': 0.36.2
'@lexical/utils': 0.36.2
'@lexical/yjs': 0.36.2([email protected])
- lexical: 0.36.2
+ lexical: 0.37.0
react: 19.1.1
react-dom: 19.1.1([email protected])
react-error-boundary: 6.0.0([email protected])
@@ -10689,11 +10688,11 @@ snapshots:
'@lexical/dragon': 0.36.2
'@lexical/selection': 0.36.2
'@lexical/utils': 0.36.2
- lexical: 0.36.2
+ lexical: 0.37.0
'@lexical/[email protected]':
dependencies:
- lexical: 0.36.2
+ lexical: 0.37.0
'@lexical/[email protected]':
dependencies:
@@ -10704,7 +10703,7 @@ snapshots:
'@lexical/clipboard': 0.36.2
'@lexical/extension': 0.36.2
'@lexical/utils': 0.36.2
- lexical: 0.36.2
+ lexical: 0.37.0
'@lexical/[email protected]':
dependencies:
@@ -10715,14 +10714,14 @@ snapshots:
'@lexical/[email protected]':
dependencies:
- lexical: 0.36.2
+ lexical: 0.37.0
'@lexical/[email protected]':
dependencies:
'@lexical/list': 0.36.2
'@lexical/selection': 0.36.2
'@lexical/table': 0.36.2
- lexical: 0.36.2
+ lexical: 0.37.0
'@lexical/[email protected]':
dependencies:
@@ -10735,7 +10734,7 @@ snapshots:
dependencies:
'@lexical/offset': 0.36.2
'@lexical/selection': 0.36.2
- lexical: 0.36.2
+ lexical: 0.37.0
yjs: 13.6.27
@@ -15401,8 +15400,6 @@ snapshots:
prelude-ls: 1.2.1
type-check: 0.4.0
-