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

GuanMu4f7cb7cd2a1f
diff --git a/web/app/components/base/textarea/index.tsx b/web/app/components/base/textarea/index.tsx
index 63eae48e319..7813eb72098 100644
--- a/web/app/components/base/textarea/index.tsx
+++ b/web/app/components/base/textarea/index.tsx
@@ -25,8 +25,8 @@ export type TextareaProps = {
destructive?: boolean
styleCss?: CSSProperties
ref?: React.Ref<HTMLTextAreaElement>
- onFocus?: () => void
- onBlur?: () => void
+ onFocus?: React.FocusEventHandler<HTMLTextAreaElement>
+ onBlur?: React.FocusEventHandler<HTMLTextAreaElement>
} & React.TextareaHTMLAttributes<HTMLTextAreaElement> & VariantProps<typeof textareaVariants>
const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/condition-number.tsx b/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/condition-number.tsx
index 7016e8bd2a1..6421401a2aa 100644
--- a/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/condition-number.tsx
+++ b/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/condition-number.tsx
@@ -18,7 +18,7 @@ type ConditionNumberProps = {
nodesOutputVars: NodeOutPutVar[]
availableNodes: Node[]
isCommonVariable?: boolean
- commonVariables: { name: string, type: string }[]
+ commonVariables: { name: string; type: string; value: string }[]
} & ConditionValueMethodProps
const ConditionNumber = ({
value,
diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/condition-string.tsx b/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/condition-string.tsx
index cf85f1259bd..d5cb06e690a 100644
--- a/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/condition-string.tsx
+++ b/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/condition-string.tsx
@@ -18,7 +18,7 @@ type ConditionStringProps = {
nodesOutputVars: NodeOutPutVar[]
availableNodes: Node[]
isCommonVariable?: boolean
- commonVariables: { name: string, type: string }[]
+ commonVariables: { name: string; type: string; value: string }[]
} & ConditionValueMethodProps
const ConditionString = ({
value,
diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/types.ts b/web/app/components/workflow/nodes/knowledge-retrieval/types.ts
index 1cae4ecd3ba..65f7dc24933 100644
--- a/web/app/components/workflow/nodes/knowledge-retrieval/types.ts
+++ b/web/app/components/workflow/nodes/knowledge-retrieval/types.ts
@@ -128,6 +128,6 @@ export type MetadataShape = {
availableNumberVars?: NodeOutPutVar[]
availableNumberNodesWithParent?: Node[]
isCommonVariable?: boolean
- availableCommonStringVars?: { name: string; type: string; }[]
- availableCommonNumberVars?: { name: string; type: string; }[]
+ availableCommonStringVars?: { name: string; type: string; value: string }[]
+ availableCommonNumberVars?: { name: string; type: string; value: string }[]
}
diff --git a/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-importer.tsx b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-importer.tsx
index 6368397b740..463d87d7d18 100644
--- a/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-importer.tsx
+++ b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-importer.tsx
@@ -24,7 +24,7 @@ const JsonImporter: FC<JsonImporterProps> = ({
const [open, setOpen] = useState(false)
const [json, setJson] = useState('')
const [parseError, setParseError] = useState<any>(null)
- const importBtnRef = useRef<HTMLButtonElement>(null)
+ const importBtnRef = useRef<HTMLElement>(null)
const advancedEditing = useVisualEditorStore(state => state.advancedEditing)
const isAddingNewField = useVisualEditorStore(state => state.isAddingNewField)
const { emit } = useMittContext()
diff --git a/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/context.tsx b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/context.tsx
index 5bf4b22f111..268683aec38 100644
--- a/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/context.tsx
+++ b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/context.tsx
@@ -18,7 +18,7 @@ type VisualEditorProviderProps = {
export const VisualEditorContext = createContext<VisualEditorContextType>(null)
export const VisualEditorContextProvider = ({ children }: VisualEditorProviderProps) => {
- const storeRef = useRef<VisualEditorStore>()
+ const storeRef = useRef<VisualEditorStore | null>(null)
if (!storeRef.current)
storeRef.current = createVisualEditorStore()
diff --git a/web/app/components/workflow/nodes/llm/use-config.ts b/web/app/components/workflow/nodes/llm/use-config.ts
index 45635be3f22..d11fb6db287 100644
--- a/web/app/components/workflow/nodes/llm/use-config.ts
+++ b/web/app/components/workflow/nodes/llm/use-config.ts
@@ -23,7 +23,7 @@ const useConfig = (id: string, payload: LLMNodeType) => {
const { nodesReadOnly: readOnly } = useNodesReadOnly()
const isChatMode = useIsChatMode()
- const defaultConfig = useStore(s => s.nodesDefaultConfigs)[payload.type]
+ const defaultConfig = useStore(s => s.nodesDefaultConfigs)?.[payload.type]
const [defaultRolePrefix, setDefaultRolePrefix] = useState<{ user: string; assistant: string }>({ user: '', assistant: '' })
const { inputs, setInputs: doSetInputs } = useNodeCrud<LLMNodeType>(id, payload)
const inputRef = useRef(inputs)
diff --git a/web/app/components/workflow/nodes/llm/utils.ts b/web/app/components/workflow/nodes/llm/utils.ts
index 29591d76ad3..10c287f86bb 100644
--- a/web/app/components/workflow/nodes/llm/utils.ts
+++ b/web/app/components/workflow/nodes/llm/utils.ts
@@ -10,7 +10,7 @@ export const checkNodeValid = (_payload: LLMNodeType) => {
export const getFieldType = (field: Field) => {
const { type, items } = field
- if(field.schemaType === 'file') return 'file'
+ if(field.schemaType === 'file') return Type.file
if (type !== Type.array || !items)
return type
diff --git a/web/app/components/workflow/nodes/parameter-extractor/components/extract-parameter/import-from-tool.tsx b/web/app/components/workflow/nodes/parameter-extractor/components/extract-parameter/import-from-tool.tsx
index bfb664aef1f..d93d08a0acd 100644
--- a/web/app/components/workflow/nodes/parameter-extractor/components/extract-parameter/import-from-tool.tsx
+++ b/web/app/components/workflow/nodes/parameter-extractor/components/extract-parameter/import-from-tool.tsx
@@ -9,7 +9,10 @@ import BlockSelector from '../../../../block-selector'
import type { Param, ParamType } from '../../types'
import cn from '@/utils/classnames'
import { useStore } from '@/app/components/workflow/store'
-import type { ToolDefaultValue } from '@/app/components/workflow/block-selector/types'
+import type {
+ DataSourceDefaultValue,
+ ToolDefaultValue,
+} from '@/app/components/workflow/block-selector/types'
import type { ToolParameter } from '@/app/components/tools/types'
import { CollectionType } from '@/app/components/tools/types'
import type { BlockEnum } from '@/app/components/workflow/types'
@@ -43,8 +46,11 @@ const ImportFromTool: FC<Props> = ({
const customTools = useStore(s => s.customTools)
const workflowTools = useStore(s => s.workflowTools)
- const handleSelectTool = useCallback((_type: BlockEnum, toolInfo?: ToolDefaultValue) => {
- const { provider_id, provider_type, tool_name } = toolInfo!
+ const handleSelectTool = useCallback((_type: BlockEnum, toolInfo?: ToolDefaultValue | DataSourceDefaultValue) => {
+ if (!toolInfo || 'datasource_name' in toolInfo)
+ return
+
+ const { provider_id, provider_type, tool_name } = toolInfo
const currentTools = (() => {
switch (provider_type) {
case CollectionType.builtIn: