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-coretoolsretrievercreate_retriever_tool
    Function●Since v0.2

    create_retriever_tool

    Create a tool to do retrieval of documents.

    Copy
    create_retriever_tool(
      retriever: BaseRetriever,
      name: str,
      description: str,
      *,
      document_prompt: BasePromptTemplate | None = None,
      document_separator: str = '\n\n',
      response_format: Literal['content', 'content_and_artifact'] = 'content'
    ) -> StructuredTool

    Used in Docs

    • BoxRetriever integration
    • EgnyteRetriever

    Parameters

    NameTypeDescription
    retriever*BaseRetriever

    The retriever to use for the retrieval

    name*str

    The name for the tool.

    This will be passed to the language model, so should be unique and somewhat descriptive.

    description*str

    The description for the tool.

    This will be passed to the language model, so should be descriptive.

    document_promptBasePromptTemplate | None
    Default:None

    The prompt to use for the document.

    document_separatorstr
    Default:'\n\n'

    The separator to use between documents.

    response_formatLiteral['content', 'content_and_artifact']
    Default:'content'

    The tool response format.

    If 'content' then the output of the tool is interpreted as the contents of a ToolMessage. If 'content_and_artifact' then the output is expected to be a two-tuple corresponding to the (content, artifact) of a ToolMessage (artifact being a list of documents in this case).

    View source on GitHub