create_vectorstore_router_agent() — langchain Function Reference
Architecture documentation for the create_vectorstore_router_agent() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 34580808_f24e_fd3f_7c49_fec246734be3["create_vectorstore_router_agent()"] 0b110498_4d8b_6b74_0801_db8fcf688f67["base.py"] 34580808_f24e_fd3f_7c49_fec246734be3 -->|defined in| 0b110498_4d8b_6b74_0801_db8fcf688f67 style 34580808_f24e_fd3f_7c49_fec246734be3 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/agents/agent_toolkits/vectorstore/base.py lines 133–230
def create_vectorstore_router_agent(
llm: BaseLanguageModel,
toolkit: VectorStoreRouterToolkit,
callback_manager: BaseCallbackManager | None = None,
prefix: str = ROUTER_PREFIX,
verbose: bool = False, # noqa: FBT001,FBT002
agent_executor_kwargs: dict[str, Any] | None = None,
**kwargs: Any,
) -> AgentExecutor:
"""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:
```bash
pip install -U langgraph
```
```python
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()
```
Args:
llm: LLM that will be used by the agent
toolkit: Set of tools for the agent which have routing capability with multiple
vector stores
callback_manager: Object to handle the callback
prefix: The prefix prompt for the router agent.
If not provided uses default `ROUTER_PREFIX`.
verbose: If you want to see the content of the scratchpad.
agent_executor_kwargs: If there is any other parameter you want to send to the
agent.
kwargs: Additional named parameters to pass to the `ZeroShotAgent`.
Returns:
Returns a callable `AgentExecutor` object.
Either you can call it or use run method with the query to get the response.
Domain
Subdomains
Source
Frequently Asked Questions
What does create_vectorstore_router_agent() do?
create_vectorstore_router_agent() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/agents/agent_toolkits/vectorstore/base.py.
Where is create_vectorstore_router_agent() defined?
create_vectorstore_router_agent() is defined in libs/langchain/langchain_classic/agents/agent_toolkits/vectorstore/base.py at line 133.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free