mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-11 03:46:52 +08:00
refactor: type improvements that doesn't modify functionality (#17970)
This commit is contained in:
@@ -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) => {
|
||||
|
||||
@@ -59,7 +59,7 @@ export const useWorkflowNodeFinished = () => {
|
||||
incomeEdges.forEach((edge) => {
|
||||
edge.data = {
|
||||
...edge.data,
|
||||
_targetRunningStatus: data.status as any,
|
||||
_targetRunningStatus: data.status,
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -47,7 +47,7 @@ export const useWorkflowNodeIterationFinished = () => {
|
||||
incomeEdges.forEach((edge) => {
|
||||
edge.data = {
|
||||
...edge.data,
|
||||
_targetRunningStatus: data.status as any,
|
||||
_targetRunningStatus: data.status,
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -44,7 +44,7 @@ export const useWorkflowNodeLoopFinished = () => {
|
||||
incomeEdges.forEach((edge) => {
|
||||
edge.data = {
|
||||
...edge.data,
|
||||
_targetRunningStatus: data.status as any,
|
||||
_targetRunningStatus: data.status,
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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])
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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#']),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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])
|
||||
|
||||
@@ -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#']),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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')}
|
||||
/>
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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([
|
||||
|
||||
@@ -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: (() => {
|
||||
|
||||
Reference in New Issue
Block a user