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

This commit is contained in:
yusheng chen
2025-04-14 16:06:10 +08:00
committed by GitHub
parent 53efb2bad5
commit 4c99e9dc73
39 changed files with 69 additions and 63 deletions

View File

@@ -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) => {

View File

@@ -59,7 +59,7 @@ export const useWorkflowNodeFinished = () => {
incomeEdges.forEach((edge) => {
edge.data = {
...edge.data,
_targetRunningStatus: data.status as any,
_targetRunningStatus: data.status,
}
})
})

View File

@@ -47,7 +47,7 @@ export const useWorkflowNodeIterationFinished = () => {
incomeEdges.forEach((edge) => {
edge.data = {
...edge.data,
_targetRunningStatus: data.status as any,
_targetRunningStatus: data.status,
}
})
})

View File

@@ -44,7 +44,7 @@ export const useWorkflowNodeLoopFinished = () => {
incomeEdges.forEach((edge) => {
edge.data = {
...edge.data,
_targetRunningStatus: data.status as any,
_targetRunningStatus: data.status,
}
})
})

View File

@@ -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}

View File

@@ -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}

View File

@@ -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])

View File

@@ -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}

View File

@@ -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#']),
},
)
}

View File

@@ -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])

View File

@@ -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#']),
},
)
}

View File

@@ -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')}
/>

View File

@@ -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,

View File

@@ -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([

View File

@@ -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: (() => {