LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Caches
    • Callbacks
    • Documents
    • Document loaders
    • Embeddings
    • Exceptions
    • Language models
    • Serialization
    • Output parsers
    • Prompts
    • Rate limiters
    • Retrievers
    • Runnables
    • Utilities
    • Vector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewCachesCallbacksDocumentsDocument loadersEmbeddingsExceptionsLanguage modelsSerializationOutput parsersPromptsRate limitersRetrieversRunnablesUtilitiesVector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-coretoolssimpleToolfrom_function
    Methodā—Since v0.2

    from_function

    Copy
    from_function(
      cls,
      func: Callable | None,
      name: str,
      description: str
    View source on GitHub
    ,
    return_direct
    :
    bool
    =
    False
    ,
    args_schema
    :
    ArgsSchema
    |
    None
    =
    None
    ,
    coroutine
    :
    Callable
    [
    .
    .
    .
    ,
    Awaitable
    [
    Any
    ]
    ]
    |
    None
    =
    None
    ,
    **
    kwargs
    :
    Any
    =
    {
    }
    )
    ->
    Tool

    Parameters

    NameTypeDescription
    func*Callable | None

    The function to create the tool from.

    name*str

    The name of the tool.

    description*str

    The description of the tool.

    return_directbool
    Default:False
    args_schemaArgsSchema | None
    Default:None
    coroutineCallable[..., Awaitable[Any]] | None
    Default:None
    **kwargsAny
    Default:{}

    Initialize tool from a function.

    Whether to return the output directly.

    The schema of the tool's input arguments.

    The asynchronous version of the function.

    Additional arguments to pass to the tool.