create_vectorstore_agent() — langchain Function Reference
Architecture documentation for the create_vectorstore_agent() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 8ef49e7b_3127_0f38_05f9_ffa5417c968c["create_vectorstore_agent()"] ce87a6d2_8bc8_e573_64ca_a0c97fddcca7["base.py"] 8ef49e7b_3127_0f38_05f9_ffa5417c968c -->|defined in| ce87a6d2_8bc8_e573_64ca_a0c97fddcca7 style 8ef49e7b_3127_0f38_05f9_ffa5417c968c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/agents/agent_toolkits/vectorstore/base.py lines 36–116
def create_vectorstore_agent(
llm: BaseLanguageModel,
toolkit: VectorStoreToolkit,
callback_manager: BaseCallbackManager | None = None,
prefix: str = PREFIX,
verbose: bool = False, # noqa: FBT001,FBT002
agent_executor_kwargs: dict[str, Any] | None = None,
**kwargs: Any,
) -> AgentExecutor:
"""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:
```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)
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()
```
Args:
llm: LLM that will be used by the agent
toolkit: Set of tools for the agent
callback_manager: Object to handle the callback
prefix: The prefix prompt for the agent.
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.
"""
tools = toolkit.get_tools()
prompt = ZeroShotAgent.create_prompt(tools, prefix=prefix)
llm_chain = LLMChain(
llm=llm,
prompt=prompt,
callback_manager=callback_manager,
)
tool_names = [tool.name for tool in tools]
agent = ZeroShotAgent(llm_chain=llm_chain, allowed_tools=tool_names, **kwargs)
return AgentExecutor.from_agent_and_tools(
agent=agent,
tools=tools,
callback_manager=callback_manager,
verbose=verbose,
**(agent_executor_kwargs or {}),
)
Domain
Subdomains
Source
Frequently Asked Questions
What does create_vectorstore_agent() do?
create_vectorstore_agent() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/agents/agent_toolkits/vectorstore/base.py.
Where is create_vectorstore_agent() defined?
create_vectorstore_agent() is defined in libs/langchain/langchain_classic/agents/agent_toolkits/vectorstore/base.py at line 36.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free