create_retriever_tool#
- langchain_core.tools.retriever.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',
Create a tool to do retrieval of documents.
- Parameters:
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_prompt (Optional[BasePromptTemplate]) – The prompt to use for the document. Defaults to None.
document_separator (str) – The separator to use between documents. Defaults to “nn”.
response_format (Literal['content', 'content_and_artifact']) – 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). Defaults to “content”.
- Returns:
Tool class to pass to an agent.
- Return type:
Examples using create_retriever_tool