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

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

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

    create_vectorstore_router_agent

    Copy
    create_vectorstore_router_agent(
      llm: BaseLanguageModel,
      toolkit: VectorStoreRouterToolkit,
      callback_manager: BaseCallbackManager | None = None,
      prefix: str = ROUTER_PREFIX,
      verbose: bool = False,
      agent_executor_kwargs: dict[str, Any] | None = None,
      **kwargs: Any = {}
    ) -> AgentExecutor
    View source on GitHub

    Parameters

    NameTypeDescription
    llm*BaseLanguageModel
    toolkit*VectorStoreRouterToolkit
    callback_managerBaseCallbackManager | None
    Default:None
    prefixstr

    Construct a VectorStore router 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)
    
    pet_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(),
    )
    
    food_vector_store = InMemoryVectorStore.from_texts(
        [
            "Carrots are orange and delicious.",
            "Apples are red and delicious.",
        ],
        OpenAIEmbeddings(),
    )
    
    tools = [
        create_retriever_tool(
            pet_vector_store.as_retriever(),
            "pet_information_retriever",
            "Fetches information about pets.",
        ),
        create_retriever_tool(
            food_vector_store.as_retriever(),
            "food_information_retriever",
            "Fetches information about food.",
        ),
    ]
    
    agent = create_react_agent(model, tools)
    
    for step in agent.stream(
        {"messages": [("human", "Tell me about carrots.")]},
        stream_mode="values",
    ):
        step["messages"][-1].pretty_print()
    Default:ROUTER_PREFIX
    verbosebool
    Default:False
    agent_executor_kwargsdict[str, Any] | None
    Default:None
    kwargsAny
    Default:{}

    LLM that will be used by the agent

    Set of tools for the agent which have routing capability with multiple vector stores

    Object to handle the callback

    The prefix prompt for the router agent. If not provided uses default ROUTER_PREFIX.

    If you want to see the content of the scratchpad.

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

    Additional named parameters to pass to the ZeroShotAgent.