data formatting

This commit is contained in:
JzoNg
2025-06-06 16:42:13 +08:00
parent ed2d971cf9
commit 57e1b896cd
4 changed files with 60 additions and 18 deletions

View File

@ -28,6 +28,7 @@ import type { IfElseNodeType } from '../nodes/if-else/types'
import { branchNameCorrect } from '../nodes/if-else/utils'
import type { IterationNodeType } from '../nodes/iteration/types'
import type { LoopNodeType } from '../nodes/loop/types'
import type { ToolNodeType } from '../nodes/tool/types'
import {
getIterationStartNode,
getLoopStartNode,
@ -276,6 +277,7 @@ export const initialNodes = (originNodes: Node[], originEdges: Edge[]) => {
if (node.data.type === BlockEnum.ParameterExtractor)
(node as any).data.model.provider = correctModelProvider((node as any).data.model.provider)
if (node.data.type === BlockEnum.HttpRequest && !node.data.retry_config) {
node.data.retry_config = {
retry_enabled: true,
@ -284,6 +286,22 @@ export const initialNodes = (originNodes: Node[], originEdges: Edge[]) => {
}
}
if (node.data.type === BlockEnum.Tool) {
const toolConfigurations = (node as Node<ToolNodeType>).data.tool_configurations
if (toolConfigurations && Object.keys(toolConfigurations).length > 0) {
const newValues = { ...toolConfigurations }
Object.keys(toolConfigurations).forEach((key) => {
if (typeof toolConfigurations[key] !== 'object') {
newValues[key] = {
type: 'constant',
value: toolConfigurations[key],
}
}
});
(node as Node<ToolNodeType>).data.tool_configurations = newValues
}
}
return node
})
}