mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 19:00:59 +03:00
Bugfix/Zod Parsing (#5399)
* implement parseWithTypeConversion - parse a value against a Zod schema with automatic type conversion for common type mismatches * Enhance parseWithTypeConversion to include maxDepth parameter for recursion control, preventing infinite loops during parsing.
This commit is contained in:
@@ -3,7 +3,7 @@ import { CallbackManager, CallbackManagerForToolRun, Callbacks, parseCallbackCon
|
||||
import { BaseDynamicToolInput, DynamicTool, StructuredTool, ToolInputParsingException } from '@langchain/core/tools'
|
||||
import { BaseRetriever } from '@langchain/core/retrievers'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, resolveFlowObjValue } from '../../../src/utils'
|
||||
import { getBaseClasses, resolveFlowObjValue, parseWithTypeConversion } from '../../../src/utils'
|
||||
import { SOURCE_DOCUMENTS_PREFIX } from '../../../src/agents'
|
||||
import { RunnableConfig } from '@langchain/core/runnables'
|
||||
import { VectorStoreRetriever } from '@langchain/core/vectorstores'
|
||||
@@ -58,7 +58,7 @@ class DynamicStructuredTool<T extends z.ZodObject<any, any, any, any> = z.ZodObj
|
||||
}
|
||||
let parsed
|
||||
try {
|
||||
parsed = await this.schema.parseAsync(arg)
|
||||
parsed = await parseWithTypeConversion(this.schema, arg)
|
||||
} catch (e) {
|
||||
throw new ToolInputParsingException(`Received tool input did not match expected schema`, JSON.stringify(arg))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user