• Preparing search index...
  • The search index is not available
LangChain.js
  • LangChain.js
  • @langchain/core
  • tools
  • tool

Function tool

  • tool<SchemaT, ToolOutputT>(func, fields): DynamicTool<ToolOutputT>
  • Creates a new StructuredTool instance with the provided function, name, description, and schema.

    Schema can be provided as Zod or JSON schema, and both will be validated.

    Type Parameters

    • SchemaT extends ZodString

      The input schema for the tool.

    • ToolOutputT = any

      The output type of the tool.

    Parameters

    • func: RunnableFunc<SchemaT extends ZodString
          ? output<SchemaT<SchemaT>>
          : string, ToolOutputT, ToolRunnableConfig>

      The function to invoke when the tool is called.

    • fields: ToolWrapperParams<SchemaT>

      An object containing the following properties:

    Returns DynamicTool<ToolOutputT>

    A new StructuredTool instance.

    Function

    • Defined in langchain-core/src/tools/index.ts:548
  • tool<SchemaT, SchemaOutputT, SchemaInputT, ToolOutputT>(func, fields): DynamicStructuredTool<SchemaT, SchemaOutputT, SchemaInputT, ToolOutputT>
  • Type Parameters

    • SchemaT extends ZodObjectAny
    • SchemaOutputT = output<SchemaT>
    • SchemaInputT = input<SchemaT>
    • ToolOutputT = any

    Parameters

    • func: RunnableFunc<SchemaOutputT, ToolOutputT, ToolRunnableConfig>
    • fields: ToolWrapperParams<SchemaT>

    Returns DynamicStructuredTool<SchemaT, SchemaOutputT, SchemaInputT, ToolOutputT>

    • Defined in langchain-core/src/tools/index.ts:557
  • tool<SchemaT, SchemaOutputT, SchemaInputT, ToolOutputT>(func, fields): DynamicStructuredTool<SchemaT, SchemaOutputT, SchemaInputT, ToolOutputT>
  • Type Parameters

    • SchemaT extends JsonSchema7Type
    • SchemaOutputT = ToolInputSchemaOutputType<SchemaT>
    • SchemaInputT = ToolInputSchemaInputType<SchemaT>
    • ToolOutputT = any

    Parameters

    • func: RunnableFunc<ToolInputSchemaOutputType<SchemaT>, ToolOutputT, ToolRunnableConfig>
    • fields: ToolWrapperParams<SchemaT>

    Returns DynamicStructuredTool<SchemaT, SchemaOutputT, SchemaInputT, ToolOutputT>

    • Defined in langchain-core/src/tools/index.ts:567

Settings

Member Visibility
LangChain.js
  • Loading...

Generated using TypeDoc