LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • MCP Adapters
    • Overview
    • Agents
    • Callbacks
    • Chains
    • Chat models
    • Embeddings
    • Evaluation
    • Globals
    • Hub
    • Memory
    • Output parsers
    • Retrievers
    • Runnables
    • LangSmith
    • Storage
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    MCP Adapters
    OverviewAgentsCallbacksChainsChat modelsEmbeddingsEvaluationGlobalsHubMemoryOutput parsersRetrieversRunnablesLangSmithStorage
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-classicagentsagent_toolkitsvectorstorebasecreate_vectorstore_agent
    Function●Since v1.0Deprecated

    create_vectorstore_agent

    Construct a VectorStore agent from an LLM and tools.

    Note

    This class is deprecated. See below for a replacement that uses tool calling methods and LangGraph. Install LangGraph with:

    pip install -U langgraph
    from langchain_core.tools import create_retriever_tool
    from langchain_core.vectorstores import InMemoryVectorStore
    from langchain_openai import ChatOpenAI, OpenAIEmbeddings
    from langgraph.prebuilt import create_react_agent
    
    model = ChatOpenAI(model="gpt-4o-mini", temperature=0)
    
    vector_store = InMemoryVectorStore.from_texts(
        [
            "Dogs are great companions, known for their loyalty and friendliness.",
            "Cats are independent pets that often enjoy their own space.",
        ],
        OpenAIEmbeddings(),
    )
    
    tool = create_retriever_tool(
        vector_store.as_retriever(),
        "pet_information_retriever",
        "Fetches information about pets.",
    )
    
    agent = create_react_agent(model, [tool])
    
    for step in agent.stream(
        {"messages": [("human", "What are dogs known for?")]},
        stream_mode="values",
    ):
        step["messages"][-1].pretty_print()
    Copy
    create_vectorstore_agent(
      llm: BaseLanguageModel,
      toolkit: VectorStoreToolkit,
      callback_manager: BaseCallbackManager | None = None,
      prefix: str = PREFIX,
      verbose: bool = False,
      agent_executor_kwargs: dict[str, Any] | None = None,
      **kwargs: Any = {}
    ) -> AgentExecutor

    Parameters

    NameTypeDescription
    llm*BaseLanguageModel

    LLM that will be used by the agent

    toolkit*VectorStoreToolkit

    Set of tools for the agent

    callback_managerBaseCallbackManager | None
    Default:None

    Object to handle the callback

    prefixstr
    Default:PREFIX

    The prefix prompt for the agent.

    verbosebool
    Default:False

    If you want to see the content of the scratchpad.

    agent_executor_kwargsdict[str, Any] | None
    Default:None

    If there is any other parameter you want to send to the agent.

    kwargsAny
    Default:{}

    Additional named parameters to pass to the ZeroShotAgent.

    View source on GitHub