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.

refactor: type improvements that doesn't modify functionality (#17970)

yusheng chen4c99e9dc7372
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 20bf2137c28..eb23da2ae02 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
@@ -124,7 +124,7 @@ const ConfigPopup: FC<PopupProps> = ({
)
const configuredProviderPanel = () => {
- const configuredPanels: any[] = []
+ const configuredPanels: JSX.Element[] = []
if (langSmithConfig)
configuredPanels.push(langSmithPanel)
@@ -139,7 +139,7 @@ const ConfigPopup: FC<PopupProps> = ({
}
const moreProviderPanel = () => {
- const notConfiguredPanels: any[] = []
+ const notConfiguredPanels: JSX.Element[] = []
if (!langSmithConfig)
notConfiguredPanels.push(langSmithPanel)
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 b638a2ebdfa..4b773c01bae 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
@@ -73,7 +73,7 @@ const AgentTools: FC = () => {
formattingChangedDispatcher()
}
- const handleToolAuthSetting = (value: any) => {
+ const handleToolAuthSetting = (value: AgentToolWithMoreInfo) => {
const newModelConfig = produce(modelConfig, (draft) => {
const tool = (draft.agentConfig.tools).find((item: any) => item.provider_id === value?.collection?.id && item.tool_name === value?.tool_name)
if (tool)
@@ -121,7 +121,7 @@ const AgentTools: FC = () => {
}
headerRight={
<div className='flex items-center'>
- <div className='text-xs font-normal leading-[18px] text-text-tertiary'>{tools.filter((item: any) => !!item.enabled).length}/{tools.length}&nbsp;{t('appDebug.agent.tools.enabled')}</div>
+ <div className='text-xs font-normal leading-[18px] text-text-tertiary'>{tools.filter(item => !!item.enabled).length}/{tools.length}&nbsp;{t('appDebug.agent.tools.enabled')}</div>
{tools.length < MAX_TOOLS_NUM && (
<>
<div className='ml-3 mr-1 h-3.5 w-px bg-divider-regular'></div>
@@ -273,7 +273,7 @@ const AgentTools: FC = () => {
{isShowSettingTool && (
<SettingBuiltInTool
toolName={currentTool?.tool_name as string}
- setting={currentTool?.tool_parameters as any}
+ setting={currentTool?.tool_parameters}
collection={currentTool?.collection as Collection}
isBuiltIn={currentTool?.collection?.type === CollectionType.builtIn}
isModel={currentTool?.collection?.type === CollectionType.model}
@@ -291,7 +291,7 @@ const AgentTools: FC = () => {
type: 'success',
message: t('common.api.actionSuccess'),
})
- handleToolAuthSetting(currentTool as any)
+ handleToolAuthSetting(currentTool)
setShowSettingAuth(false)
}}
/>
diff --git a/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx b/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx
index 30125a12d1d..75183ab5a72 100644
--- a/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx
+++ b/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx
@@ -56,8 +56,8 @@ const SettingBuiltInTool: FC<Props> = ({
const [tools, setTools] = useState<Tool[]>([])
const currTool = tools.find(tool => tool.name === toolName)
const formSchemas = currTool ? toolParametersToFormSchemas(currTool.parameters) : []
- const infoSchemas = formSchemas.filter((item: any) => item.form === 'llm')
- const settingSchemas = formSchemas.filter((item: any) => item.form !== 'llm')
+ const infoSchemas = formSchemas.filter(item => item.form === 'llm')
+ const settingSchemas = formSchemas.filter(item => item.form !== 'llm')
const hasSetting = settingSchemas.length > 0
const [tempSetting, setTempSetting] = useState(setting)
const [currType, setCurrType] = useState('info')
@@ -99,7 +99,7 @@ const SettingBuiltInTool: FC<Props> = ({
const isValid = (() => {
let valid = true
- settingSchemas.forEach((item: any) => {
+ settingSchemas.forEach((item) => {
if (item.required && !tempSetting[item.name])
valid = false
})
@@ -120,7 +120,7 @@ const SettingBuiltInTool: FC<Props> = ({
<div className=''>
{infoSchemas.length > 0 && (
<div className='space-y-1 py-2'>
- {infoSchemas.map((item: any, index) => (
+ {infoSchemas.map((item, index) => (
<div key={index} className='py-1'>
<div className='flex items-center gap-2'>
<div className='code-sm-semibold text-text-secondary'>{item.label[language]}</div>
@@ -147,7 +147,7 @@ const SettingBuiltInTool: FC<Props> = ({
<Form
value={tempSetting}
onChange={setTempSetting}
- formSchemas={settingSchemas as any}
+ formSchemas={settingSchemas}
isEditMode={false}
showOnVariableMap={{}}
validating={false}
diff --git a/web/app/components/app/configuration/dataset-config/params-config/config-content.tsx b/web/app/components/app/configuration/dataset-config/params-config/config-content.tsx
index 3b9078f1beb..86025f68fab 100644
--- a/web/app/components/app/configuration/dataset-config/params-config/config-content.tsx
+++ b/web/app/components/app/configuration/dataset-config/params-config/config-content.tsx
@@ -368,8 +368,8 @@ const ConfigContent: FC<Props> = ({
provider={model?.provider}
completionParams={model?.completion_params}
modelId={model?.name}
- setModel={onSingleRetrievalModelChange as any}
- onCompletionParamsChange={onSingleRetrievalModelParamsChange as any}
+ setModel={onSingleRetrievalModelChange}
+ onCompletionParamsChange={onSingleRetrievalModelParamsChange}
hideDebugWithMultipleModel
debugWithMultipleModel={false}
/>
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 e74dff40995..17d04acdc7d 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
@@ -8,6 +8,7 @@ import ModelParameterModal from '@/app/components/header/account-setting/model-p
import ModelIcon from '@/app/components/header/account-setting/model-provider-page/model-icon'
import ModelName from '@/app/components/header/account-setting/model-provider-page/model-name'
import {
+ type FormValue,
MODEL_STATUS_TEXT,
ModelStatusEnum,
} from '@/app/components/header/account-setting/model-provider-page/declarations'
@@ -45,7 +46,7 @@ const ModelParameterTrigger: FC<ModelParameterTriggerProps> = ({
}
onMultipleModelConfigsChange(true, newModelConfigs)
}
- const handleParamsChange = (params: any) => {
+ const handleParamsChange = (params: FormValue) => {
const newModelConfigs = [...multipleModelConfigs]
newModelConfigs[index] = {
...newModelConfigs[index],
diff --git a/web/app/components/app/configuration/index.tsx b/web/app/components/app/configuration/index.tsx
index 249624a294c..b7b80ea080f 100644
--- a/web/app/components/app/configuration/index.tsx
+++ b/web/app/components/app/configuration/index.tsx
@@ -227,7 +227,7 @@ const Configuration: FC = () => {
}, [modelModeType])
const [dataSets, setDataSets] = useState<DataSet[]>([])
- const contextVar = modelConfig.configs.prompt_variables.find((item: any) => item.is_context_var)?.key
+ const contextVar = modelConfig.configs.prompt_variables.find(item => item.is_context_var)?.key
const hasSetContextVar = !!contextVar
const [isShowSelectDataSet, { setTrue: showSelectDataSet, setFalse: hideSelectDataSet }] = useBoolean(false)
const selectedIds = dataSets.map(item => item.id)
@@ -245,7 +245,7 @@ const Configuration: FC = () => {
formattingChangedDispatcher()
let newDatasets = data
if (data.find(item => !item.name)) { // has not loaded selected dataset
- const newSelected = produce(data, (draft: any) => {
+ const newSelected = produce(data, (draft) => {
data.forEach((item, index) => {
if (!item.name) { // not fetched database
const newItem = dataSets.find(i => i.id === item.id)
@@ -513,7 +513,7 @@ const Configuration: FC = () => {
if (modelConfig.chat_prompt_config && modelConfig.chat_prompt_config.prompt.length > 0)
setChatPromptConfig(modelConfig.chat_prompt_config)
else
- setChatPromptConfig(clone(DEFAULT_CHAT_PROMPT_CONFIG) as any)
+ setChatPromptConfig(clone(DEFAULT_CHAT_PROMPT_CONFIG))
setCompletionPromptConfig(modelConfig.completion_prompt_config || clone(DEFAULT_COMPLETION_PROMPT_CONFIG) as any)
setCanReturnToSimpleMode(false)
}
diff --git a/web/app/components/app/configuration/prompt-value-panel/index.tsx b/web/app/components/app/configuration/prompt-value-panel/index.tsx
index 49d69d4fc0d..e509ee50e41 100644
--- a/web/app/components/app/configuration/prompt-value-panel/index.tsx
+++ b/web/app/components/app/configuration/prompt-value-panel/index.tsx
@@ -79,7 +79,7 @@ const PromptValuePanel: FC<IPromptValuePanelProps> = ({
}
const onClear = () => {
- const newInputs: Record<string, any> = {}
+ const newInputs: Inputs = {}
promptVariables.forEach((item) => {
newInputs[item.key] = ''
})
diff --git a/web/app/components/base/agent-log-modal/detail.tsx b/web/app/components/base/agent-log-modal/detail.tsx
index e7102084006..148b16815ec 100644
--- a/web/app/components/base/agent-log-modal/detail.tsx
+++ b/web/app/components/base/agent-log-modal/detail.tsx
@@ -36,7 +36,7 @@ const AgentLogDetail: FC<AgentLogDetailProps> = ({
const [list, setList] = useState<AgentIteration[]>([])
const tools = useMemo(() => {
- const res = uniq(flatten(runDetail?.iterations.map((iteration: any) => {
+ const res = uniq(flatten(runDetail?.iterations.map((iteration) => {
return iteration.tool_calls.map((tool: any) => tool.tool_name).filter(Boolean)
})).filter(Boolean))
return res
diff --git a/web/app/components/base/audio-btn/index.tsx b/web/app/components/base/audio-btn/index.tsx
index 9964d273c05..2a54a8ed73f 100644
--- a/web/app/components/base/audio-btn/index.tsx
+++ b/web/app/components/base/audio-btn/index.tsx
@@ -29,7 +29,7 @@ const AudioBtn = ({
const params = useParams()
const pathname = usePathname()
- const audio_finished_call = (event: string): any => {
+ const audio_finished_call = (event: string): void => {
switch (event) {
case 'ended':
setAudioState('ended')
diff --git a/web/app/components/base/chat/chat/hooks.ts b/web/app/components/base/chat/chat/hooks.ts
index aad17ccc529..bff222ea385 100644
--- a/web/app/components/base/chat/chat/hooks.ts
+++ b/web/app/components/base/chat/chat/hooks.ts
@@ -512,7 +512,7 @@ export const useChat = (
responseItem.workflowProcess!.tracing!.push({
...iterationStartedData,
status: WorkflowRunningStatus.Running,
- } as any)
+ })
updateCurrentQAOnTree({
placeholderQuestionId,
questionItem,
@@ -528,7 +528,7 @@ export const useChat = (
...tracing[iterationIndex],
...iterationFinishedData,
status: WorkflowRunningStatus.Succeeded,
- } as any
+ }
updateCurrentQAOnTree({
placeholderQuestionId,
@@ -547,7 +547,7 @@ export const useChat = (
responseItem.workflowProcess!.tracing!.push({
...nodeStartedData,
status: WorkflowRunningStatus.Running,
- } as any)
+ })
updateCurrentQAOnTree({
placeholderQuestionId,
questionItem,
@@ -590,7 +590,7 @@ export const useChat = (
responseItem.workflowProcess!.tracing!.push({
...loopStartedData,
status: WorkflowRunningStatus.Running,
- } as any)
+ })
updateCurrentQAOnTree({
placeholderQuestionId,
questionItem,
@@ -606,7 +606,7 @@ export const useChat = (
...tracing[loopIndex],
...loopFinishedData,
status: WorkflowRunningStatus.Succeeded,
- } as any
+ }
updateCurrentQAOnTree({
placeholderQuestionId,
diff --git a/web/app/components/base/features/new-feature-panel/annotation-reply/index.tsx b/web/app/components/base/features/new-feature-panel/annotation-reply/index.tsx
index b2cd86674d3..34ecf23c80b 100644
--- a/web/app/components/base/features/new-feature-panel/annotation-reply/index.tsx
+++ b/web/app/components/base/features/new-feature-panel/annotation-reply/index.tsx
@@ -12,6 +12,7 @@ import useAnnotationConfig from '@/app/components/base/features/new-feature-pane
import ConfigParamModal from '@/app/components/base/features/new-feature-panel/annotation-reply/config-param-modal'
import AnnotationFullModal from '@/app/components/billing/annotation-full/modal'
import { ANNOTATION_DEFAULT } from '@/config'
+import type { AnnotationReplyConfig } from '@/models/debug'
type Props = {
disabled?: boolean
@@ -30,7 +31,7 @@ const AnnotationReply = ({
const featuresStore = useFeaturesStore()
const annotationReply = useFeatures(s => s.features.annotationReply)
- const updateAnnotationReply = useCallback((newConfig: any) => {
+ const updateAnnotationReply = useCallback((newConfig: AnnotationReplyConfig) => {
const {
features,
setFeatures,
diff --git a/web/app/components/base/prompt-editor/plugins/workflow-variable-block/workflow-variable-block-replacement-block.tsx b/web/app/components/base/prompt-editor/plugins/workflow-variable-block/workflow-variable-block-replacement-block.tsx
index 0a80ecc2205..22ebc5d2480 100644
--- a/web/app/components/base/prompt-editor/plugins/workflow-variable-block/workflow-variable-block-replacement-block.tsx
+++ b/web/app/components/base/prompt-editor/plugins/workflow-variable-block/workflow-variable-block-replacement-block.tsx
@@ -47,7 +47,7 @@ const WorkflowVariableBlockReplacementBlock = ({
}
}, [])
- const transformListener = useCallback((textNode: any) => {
+ const transformListener = useCallback((textNode: CustomTextNode) => {
resetReg()
return decoratorTransform(textNode, getMatch, createWorkflowVariableBlockNode)
}, [createWorkflowVariableBlockNode, getMatch])
diff --git a/web/app/components/base/toast/index.spec.tsx b/web/app/components/base/toast/index.spec.tsx
index 7cbacfeb596..2dac8d27fff 100644
--- a/web/app/components/base/toast/index.spec.tsx
+++ b/web/app/components/base/toast/index.spec.tsx
@@ -1,3 +1,4 @@
+import type { ReactNode } from 'react'
import React from 'react'
import { act, render, screen, waitFor } from '@testing-library/react'
import Toast, { ToastProvider, useToastContext } from '.'
@@ -80,7 +81,7 @@ describe('Toast', () => {
const CustomToastContext = React.createContext({ notify: noop, close: undefined })
// Create a wrapper component using the custom context
- const Wrapper = ({ children }: any) => (
+ const Wrapper = ({ children }: { children: ReactNode }) => (
<CustomToastContext.Provider value={{ notify: noop, close: undefined }}>
{children}
</CustomToastContext.Provider>
diff --git a/web/app/components/datasets/documents/detail/embedding/index.tsx b/web/app/components/datasets/documents/detail/embedding/index.tsx
index a7d1d08ed75..e9ea72bfb68 100644
--- a/web/app/components/datasets/documents/detail/embedding/index.tsx
+++ b/web/app/components/datasets/documents/detail/embedding/index.tsx
@@ -15,6 +15,7 @@ import { RETRIEVE_METHOD } from '@/types/app'
import cn from '@/utils/classnames'
import Divider from '@/app/components/base/divider'
import { ToastContext } from '@/app/components/base/toast'
+import type { IndexingStatusResponse } from '@/models/datasets'
import { ProcessMode, type ProcessRuleResponse } from '@/models/datasets'
import type { CommonResponse } from '@/models/common'
import { asyncRunSafe, sleep } from '@/utils'
@@ -166,7 +167,7 @@ const EmbeddingDetail: FC<IEmbeddingDetailProps> = ({
const localDatasetId = dstId ?? datasetId
const localDocumentId = docId ?? documentId
- const [indexingStatusDetail, setIndexingStatusDetail] = useState<any>(null)
+ const [indexingStatusDetail, setIndexingStatusDetail] = useState<IndexingStatusResponse | null>(null)
const fetchIndexingStatus = async () => {
const status = await doFetchIndexingStatus({ datasetId: localDatasetId, documentId: localDocumentId })
setIndexingStatusDetail(status)
diff --git a/web/app/components/datasets/hit-testing/textarea.tsx b/web/app/components/datasets/hit-testing/textarea.tsx
index d9f5bb18ee2..c92e1075429 100644
--- a/web/app/components/datasets/hit-testing/textarea.tsx
+++ b/web/app/components/datasets/hit-testing/textarea.tsx
@@ -1,3 +1,4 @@
+import type { ChangeEvent } from 'react'
import React, { useState } from 'react'
import { useTranslation } from 'react-i18next'
import {
@@ -58,7 +59,7 @@ const TextAreaWithButton = ({
setIsSettingsOpen(false)
}
- function handleTextChange(event: any) {
+ function handleTextChange(event: ChangeEvent<HTMLTextAreaElement>) {
setText(event.target.value)
}
diff --git a/web/app/components/plugins/marketplace/list/card-wrapper.tsx b/web/app/components/plugins/marketplace/list/card-wrapper.tsx
index 205f5d850f0..75c9aae3d56 100644
--- a/web/app/components/plugins/marketplace/list/card-wrapper.tsx
+++ b/web/app/components/plugins/marketplace/list/card-wrapper.tsx
@@ -67,7 +67,7 @@ const CardWrapper = ({
{
isShowInstallFromMarketplace && (
<InstallFromMarketplace
- manifest={plugin as any}
+ manifest={plugin}
uniqueIdentifier={plugin.latest_package_identifier}
onClose={hideInstallFromMarketplace}
onSuccess={hideInstallFromMarketplace}
diff --git a/web/app/components/plugins/plugin-detail-panel/endpoint-card.tsx b/web/app/components/plugins/plugin-detail-panel/endpoint-card.tsx
index 000763c76c3..9ab0c5b9a37 100644
--- a/web/app/components/plugins/plugin-detail-panel/endpoint-card.tsx
+++ b/web/app/components/plugins/plugin-detail-panel/endpoint-card.tsx
@@ -108,7 +108,7 @@ const EndpointCard = ({
Toast.notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') })
},
})
- const handleUpdate = (state: any) => updateEndpoint({
+ const handleUpdate = (state: Record<string, any>) => updateEndpoint({
endpointID,
state,
})
diff --git a/web/app/components/plugins/plugin-detail-panel/endpoint-list.tsx b/web/app/components/plugins/plugin-detail-panel/endpoint-list.tsx
index abc320dbf10..59a457ecbd1 100644
--- a/web/app/components/plugins/plugin-detail-panel/endpoint-list.tsx
+++ b/web/app/components/plugins/plugin-detail-panel/endpoint-list.tsx
@@ -55,7 +55,7 @@ const EndpointList = ({ detail }: Props) => {
},
})
- const handleCreate = (state: any) => createEndpoint({
+ const handleCreate = (state: Record<string, any>) => createEndpoint({
pluginUniqueID,
state,
})
diff --git a/web/app/components/plugins/plugin-detail-panel/tool-selector/reasoning-config-form.tsx b/web/app/components/plugins/plugin-detail-panel/tool-selector/reasoning-config-form.tsx
index 8e69c7d704f..0d137502f4a 100644
--- a/web/app/components/plugins/plugin-detail-panel/tool-selector/reasoning-config-form.tsx
+++ b/web/app/components/plugins/plugin-detail-panel/tool-selector/reasoning-config-form.tsx
@@ -245,7 +245,7 @@ const ReasoningConfigForm: React.FC<Props> = ({
popupClassName='!w-[387px]'
isAdvancedMode
isInWorkflow
- value={varInput as any}
+ value={varInput}
setModel={handleModelChange(variable)}
scope={scope}
/>
diff --git a/web/app/components/plugins/provider-card.tsx b/web/app/components/plugins/provider-card.tsx
index 3c535a67fab..a0643fba205 100644
--- a/web/app/components/plugins/provider-card.tsx
+++ b/web/app/components/plugins/provider-card.tsx
@@ -83,7 +83,7 @@ const ProviderCard: FC<Props> = ({
{
isShowInstallFromMarketplace && (
<InstallFromMarketplace
- manifest={payload as any}
+ manifest={payload}
uniqueIdentifier={payload.latest_package_identifier}
onClose={hideInstallFromMarketplace}
onSuccess={() => hideInstallFromMarketplace()}
diff --git a/web/app/components/share/text-generation/result/index.tsx b/web/app/components/share/text-generation/result/index.tsx
index 6a52da8f4b6..97a3a773956 100644
--- a/web/app/components/share/text-generation/result/index.tsx
+++ b/web/app/components/share/text-generation/result/index.tsx
@@ -218,7 +218,7 @@ const Result: FC<IResultProps> = ({
...data,
status: NodeRunningStatus.Running,
expand: true,
- } as any)
+ })
}))
},
onIterationNext: () => {
@@ -237,7 +237,7 @@ const Result: FC<IResultProps> = ({
draft.tracing[iterationsIndex] = {
...data,
expand: !!data.error,
- } as any
+ }
}))
},
onLoopStart: ({ data }) => {
@@ -247,7 +247,7 @@ const Result: FC<IResultProps> = ({
...data,
status: NodeRunningStatus.Running,
expand: true,
- } as any)
+ })
}))
},
onLoopNext: () => {
@@ -266,7 +266,7 @@ const Result: FC<IResultProps> = ({
draft.tracing[loopsIndex] = {
...data,
expand: !!data.error,
- } as any
+ }
}))
},
onNodeStarted: ({ data }) => {
@@ -282,7 +282,7 @@ const Result: FC<IResultProps> = ({
...data,
status: NodeRunningStatus.Running,
expand: true,
- } as any)
+ })
}))
},
onNodeFinished: ({ data }) => {
@@ -302,7 +302,7 @@ const Result: FC<IResultProps> = ({
: {}),
...data,
expand: !!data.error,
- } as any
+ }
}
}))
},
diff --git a/web/app/components/tools/utils/to-form-schema.ts b/web/app/components/tools/utils/to-form-schema.ts
index 6dc51e16ade..179f59021ea 100644
--- a/web/app/components/tools/utils/to-form-schema.ts
+++ b/web/app/components/tools/utils/to-form-schema.ts
@@ -78,7 +78,7 @@ export const generateFormValue = (value: Record<string, any>, formSchemas: { var
}
export const getPlainValue = (value: Record<string, any>) => {
- const plainValue = { ...value } as any
+ const plainValue = { ...value }
Object.keys(plainValue).forEach((key) => {
plainValue[key] = value[key].value
})
diff --git a/web/app/components/workflow/block-selector/tools.tsx b/web/app/components/workflow/block-selector/tools.tsx
index c947e464926..2562501524c 100644
--- a/web/app/components/workflow/block-selector/tools.tsx
+++ b/web/app/components/workflow/block-selector/tools.tsx
@@ -55,7 +55,7 @@ const Blocks = ({
}
}
*/
- const { letters, groups: withLetterAndGroupViewToolsData } = groupItems(tools, tool => (tool as any).label[language][0])
+ const { letters, groups: withLetterAndGroupViewToolsData } = groupItems(tools, tool => tool.label[language][0])
const treeViewToolsData = useMemo(() => {
const result: Record<string, ToolWithProvider[]> = {}
Object.keys(withLetterAndGroupViewToolsData).forEach((letter) => {
diff --git a/web/app/components/workflow/hooks/use-workflow-run-event/use-workflow-node-finished.ts b/web/app/components/workflow/hooks/use-workflow-run-event/use-workflow-node-finished.ts
index b8490ff14c7..85382e57968 100644
--- a/web/app/components/workflow/hooks/use-workflow-run-event/use-workflow-node-finished.ts
+++ b/web/app/components/workflow/hooks/use-workflow-run-event/use-workflow-node-finished.ts
@@ -59,7 +59,7 @@ export const useWorkflowNodeFinished = () => {
incomeEdges.forEach((edge) => {
edge.data = {
...edge.data,
- _targetRunningStatus: data.status as any,
+ _targetRunningStatus: data.status,
}
})
})
diff --git a/web/app/components/workflow/hooks/use-workflow-run-event/use-workflow-node-iteration-finished.ts b/web/app/components/workflow/hooks/use-workflow-run-event/use-workflow-node-iteration-finished.ts
index 491628cf0b9..7da8665c66e 100644
--- a/web/app/components/workflow/hooks/use-workflow-run-event/use-workflow-node-iteration-finished.ts
+++ b/web/app/components/workflow/hooks/use-workflow-run-event/use-workflow-node-iteration-finished.ts
@@ -47,7 +47,7 @@ export const useWorkflowNodeIterationFinished = () => {
incomeEdges.forEach((edge) => {
edge.data = {
...edge.data,
- _targetRunningStatus: data.status as any,
+ _targetRunningStatus: data.status,
}
})
})
diff --git a/web/app/components/workflow/hooks/use-workflow-run-event/use-workflow-node-loop-finished.ts b/web/app/components/workflow/hooks/use-workflow-run-event/use-workflow-node-loop-finished.ts
index 0efe5308071..5b6c7f005f8 100644
--- a/web/app/components/workflow/hooks/use-workflow-run-event/use-workflow-node-loop-finished.ts
+++ b/web/app/components/workflow/hooks/use-workflow-run-event/use-workflow-node-loop-finished.ts
@@ -44,7 +44,7 @@ export const useWorkflowNodeLoopFinished = () => {
incomeEdges.forEach((edge) => {
edge.data = {
...edge.data,
- _targetRunningStatus: data.status as any,
+ _targetRunningStatus: data.status,
}
})
})
diff --git a/web/app/components/workflow/nodes/document-extractor/panel.tsx b/web/app/components/workflow/nodes/document-extractor/panel.tsx
index fcb94947046..df144d56bfb 100644
--- a/web/app/components/workflow/nodes/document-extractor/panel.tsx
+++ b/web/app/components/workflow/nodes/document-extractor/panel.tsx
@@ -106,7 +106,7 @@ const Panel: FC<NodePanelProps<DocExtractorNodeType>> = ({
required: true,
}],
values: { files },
- onChange: keyValue => setFiles((keyValue as any).files),
+ onChange: keyValue => setFiles(keyValue.files),
},
]}
runningStatus={runningStatus}
diff --git a/web/app/components/workflow/nodes/iteration/panel.tsx b/web/app/components/workflow/nodes/iteration/panel.tsx
index 92dbf98450f..67e67988b22 100644
--- a/web/app/components/workflow/nodes/iteration/panel.tsx
+++ b/web/app/components/workflow/nodes/iteration/panel.tsx
@@ -155,7 +155,7 @@ const Panel: FC<NodePanelProps<IterationNodeType>> = ({
required: false,
}],
values: { [iteratorInputKey]: iterator },
- onChange: keyValue => setIterator((keyValue as any)[iteratorInputKey]),
+ onChange: keyValue => setIterator(keyValue[iteratorInputKey]),
},
]}
runningStatus={runningStatus}
diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/components/retrieval-config.tsx b/web/app/components/workflow/nodes/knowledge-retrieval/components/retrieval-config.tsx
index 7ace6c16481..8a3dc1efba7 100644
--- a/web/app/components/workflow/nodes/knowledge-retrieval/components/retrieval-config.tsx
+++ b/web/app/components/workflow/nodes/knowledge-retrieval/components/retrieval-config.tsx
@@ -84,7 +84,7 @@ const RetrievalConfig: FC<Props> = ({
model: configs.reranking_model?.reranking_model_name,
}),
reranking_mode: configs.reranking_mode,
- weights: configs.weights as any,
+ weights: configs.weights,
reranking_enable: configs.reranking_enable,
})
}, [onMultipleRetrievalConfigChange, payload.retrieval_mode, validRerankDefaultProvider, validRerankDefaultModel, onRetrievalModeChange])
diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/panel.tsx b/web/app/components/workflow/nodes/knowledge-retrieval/panel.tsx
index b2da10901ef..20fd24e50c4 100644
--- a/web/app/components/workflow/nodes/knowledge-retrieval/panel.tsx
+++ b/web/app/components/workflow/nodes/knowledge-retrieval/panel.tsx
@@ -202,7 +202,7 @@ const Panel: FC<NodePanelProps<KnowledgeRetrievalNodeType>> = ({
required: true,
}],
values: { query },
- onChange: keyValue => setQuery((keyValue as any).query),
+ onChange: keyValue => setQuery(keyValue.query),
},
]}
runningStatus={runningStatus}
diff --git a/web/app/components/workflow/nodes/llm/panel.tsx b/web/app/components/workflow/nodes/llm/panel.tsx
index 2e23bfd7e9c..58b036317d1 100644
--- a/web/app/components/workflow/nodes/llm/panel.tsx
+++ b/web/app/components/workflow/nodes/llm/panel.tsx
@@ -98,7 +98,7 @@ const Panel: FC<NodePanelProps<LLMNodeType>> = ({
required: false,
}],
values: { '#context#': contexts },
- onChange: keyValue => setContexts((keyValue as any)['#context#']),
+ onChange: keyValue => setContexts(keyValue['#context#']),
},
)
}
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 899d16dc5ba..bfb664aef1f 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
@@ -59,7 +59,7 @@ const ImportFromTool: FC<Props> = ({
})()
const currCollection = currentTools.find(item => canFindTool(item.id, provider_id))
const currTool = currCollection?.tools.find(tool => tool.name === tool_name)
- const toExactParams = (currTool?.parameters || []).filter((item: any) => item.form === 'llm')
+ const toExactParams = (currTool?.parameters || []).filter(item => item.form === 'llm')
const formattedParams = toParmExactParams(toExactParams, language)
onImport(formattedParams)
}, [buildInTools, customTools, language, onImport, workflowTools])
diff --git a/web/app/components/workflow/nodes/question-classifier/panel.tsx b/web/app/components/workflow/nodes/question-classifier/panel.tsx
index bd61e5c5fcf..96e8fabd47f 100644
--- a/web/app/components/workflow/nodes/question-classifier/panel.tsx
+++ b/web/app/components/workflow/nodes/question-classifier/panel.tsx
@@ -90,7 +90,7 @@ const Panel: FC<NodePanelProps<QuestionClassifierNodeType>> = ({
required: false,
}],
values: { '#files#': visionFiles },
- onChange: keyValue => setVisionFiles((keyValue as any)['#files#']),
+ onChange: keyValue => setVisionFiles(keyValue['#files#']),
},
)
}
diff --git a/web/app/components/workflow/panel/workflow-preview.tsx b/web/app/components/workflow/panel/workflow-preview.tsx
index 9b93ec86d12..228a376535f 100644
--- a/web/app/components/workflow/panel/workflow-preview.tsx
+++ b/web/app/components/workflow/panel/workflow-preview.tsx
@@ -117,7 +117,7 @@ const WorkflowPreview = () => {
<ResultText
isRunning={workflowRunningData?.result?.status === WorkflowRunningStatus.Running || !workflowRunningData?.result}
outputs={workflowRunningData?.resultText}
- allFiles={workflowRunningData?.result?.files as any}
+ allFiles={workflowRunningData?.result?.files}
error={workflowRunningData?.result?.error}
onClick={() => switchTab('DETAIL')}
/>
diff --git a/web/app/components/workflow/run/utils/format-log/loop/index.spec.ts b/web/app/components/workflow/run/utils/format-log/loop/index.spec.ts
index 73162cf6b45..1f70cef02cc 100644
--- a/web/app/components/workflow/run/utils/format-log/loop/index.spec.ts
+++ b/web/app/components/workflow/run/utils/format-log/loop/index.spec.ts
@@ -7,10 +7,10 @@ describe('loop', () => {
const [startNode, loopNode, ...loops] = list
const result = format(list as any, noop)
test('result should have no nodes in loop node', () => {
- expect((result as any).find((item: any) => !!item.execution_metadata?.loop_id)).toBeUndefined()
+ expect(result.find(item => !!item.execution_metadata?.loop_id)).toBeUndefined()
})
test('loop should put nodes in details', () => {
- expect(result as any).toEqual([
+ expect(result).toEqual([
startNode,
{
...loopNode,
diff --git a/web/app/components/workflow/run/utils/format-log/retry/index.spec.ts b/web/app/components/workflow/run/utils/format-log/retry/index.spec.ts
index a8f46e96b1b..2ce9554ba46 100644
--- a/web/app/components/workflow/run/utils/format-log/retry/index.spec.ts
+++ b/web/app/components/workflow/run/utils/format-log/retry/index.spec.ts
@@ -7,7 +7,7 @@ describe('retry', () => {
const [startNode, retryNode, ...retryDetail] = steps
const result = format(steps as any)
test('should have no retry status nodes', () => {
- expect(result.find(item => (item as any).status === 'retry')).toBeUndefined()
+ expect(result.find(item => item.status === 'retry')).toBeUndefined()
})
test('should put retry nodes in retryDetail', () => {
expect(result).toEqual([
diff --git a/web/app/components/workflow/utils/tool.ts b/web/app/components/workflow/utils/tool.ts
index 9fb5d5cc077..d1dda12180c 100644
--- a/web/app/components/workflow/utils/tool.ts
+++ b/web/app/components/workflow/utils/tool.ts
@@ -20,8 +20,8 @@ export const getToolCheckParams = (
const currCollection = currentTools.find(item => canFindTool(item.id, provider_id))
const currTool = currCollection?.tools.find(tool => tool.name === tool_name)
const formSchemas = currTool ? toolParametersToFormSchemas(currTool.parameters) : []
- const toolInputVarSchema = formSchemas.filter((item: any) => item.form === 'llm')
- const toolSettingSchema = formSchemas.filter((item: any) => item.form !== 'llm')
+ const toolInputVarSchema = formSchemas.filter(item => item.form === 'llm')
+ const toolSettingSchema = formSchemas.filter(item => item.form !== 'llm')
return {
toolInputsSchema: (() => {
diff --git a/web/app/education-apply/search-input.tsx b/web/app/education-apply/search-input.tsx
index 800f49fc069..63a393b3268 100644
--- a/web/app/education-apply/search-input.tsx
+++ b/web/app/education-apply/search-input.tsx
@@ -1,3 +1,4 @@
+import type { ChangeEventHandler } from 'react'
import {
useCallback,
useRef,
@@ -49,7 +50,7 @@ const SearchInput = ({
})
}, [querySchoolsWithDebounced, handleUpdateSchools])
- const handleValueChange = useCallback((e: any) => {
+ const handleValueChange: ChangeEventHandler<HTMLInputElement> = useCallback((e) => {
setOpen(true)
setSchools([])
pageRef.current = 0
diff --git a/web/utils/index.spec.ts b/web/utils/index.spec.ts
index 4785e555946..21a0d80dd0b 100644
--- a/web/utils/index.spec.ts
+++ b/web/utils/index.spec.ts
@@ -43,7 +43,7 @@ describe('asyncRunSafe', () => {
})
describe('getTextWidthWithCanvas', () => {
- let originalCreateElement: any
+ let originalCreateElement: typeof document.createElement
beforeEach(() => {
// Store original implementation
@@ -231,8 +231,8 @@ describe('canFindTool', () => {
})
describe('removeSpecificQueryParam', () => {
- let originalLocation: any
- let originalReplaceState: any
+ let originalLocation: Location
+ let originalReplaceState: typeof window.history.replaceState
beforeEach(() => {
originalLocation = window.location