• Given a runnable and a Zod schema, convert the runnable to a tool.

    Type Parameters

    • RunInput

      The input schema for the runnable.

    • RunOutput extends string = string

    Parameters

    • runnable: Runnable<RunInput, RunOutput, RunnableConfig>

      The runnable to convert to a tool.

    • fields: {
          schema: ZodString | ZodType<RunInput, ZodTypeDef, RunInput>;
          description?: string;
          name?: string;
      }
      • schema: ZodString | ZodType<RunInput, ZodTypeDef, RunInput>

        The Zod schema for the input of the tool. Either the schema itself or a ZodString.

      • Optionaldescription?: string

        The description of the tool. If not provided, it will default to Takes {schema} where schema is a JSON string representation of the input schema.

      • Optionalname?: string

        The name of the tool. If not provided, it will default to the name of the runnable.

    Returns DynamicTool | DynamicStructuredTool<z.ZodType<RunInput>>

    The tool created from the runnable. DynamicTool if the schema is a ZodString, DynamicStructuredTool if the schema is a ZodType.