mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-03 07:33:45 +00:00
experimental batch tool (#2983)
Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
@@ -29,6 +29,7 @@ export namespace Tool {
|
||||
output: string
|
||||
attachments?: MessageV2.FilePart[]
|
||||
}>
|
||||
formatValidationError?(error: z.ZodError): string
|
||||
}>
|
||||
}
|
||||
|
||||
@@ -45,7 +46,14 @@ export namespace Tool {
|
||||
const toolInfo = init instanceof Function ? await init() : init
|
||||
const execute = toolInfo.execute
|
||||
toolInfo.execute = (args, ctx) => {
|
||||
toolInfo.parameters.parse(args)
|
||||
try {
|
||||
toolInfo.parameters.parse(args)
|
||||
} catch (error) {
|
||||
if (error instanceof z.ZodError && toolInfo.formatValidationError) {
|
||||
throw new Error(toolInfo.formatValidationError(error))
|
||||
}
|
||||
throw error
|
||||
}
|
||||
return execute(args, ctx)
|
||||
}
|
||||
return toolInfo
|
||||
|
||||
Reference in New Issue
Block a user