toolkit.py — langchain Source File
Architecture documentation for toolkit.py, a python file in the langchain codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 5267c032_dda3_79c4_9c44_828c1765ed44["toolkit.py"] e929cf21_6ab8_6ff3_3765_0d35a099a053["langchain_core.language_models"] 5267c032_dda3_79c4_9c44_828c1765ed44 --> e929cf21_6ab8_6ff3_3765_0d35a099a053 121262a1_0bd6_d637_bce3_307ab6b3ecd4["langchain_core.tools"] 5267c032_dda3_79c4_9c44_828c1765ed44 --> 121262a1_0bd6_d637_bce3_307ab6b3ecd4 95e05501_5650_2f3c_99db_c054e96d4e43["langchain_core.tools.base"] 5267c032_dda3_79c4_9c44_828c1765ed44 --> 95e05501_5650_2f3c_99db_c054e96d4e43 f75e66a0_314a_f961_16d7_464ee959064b["langchain_core.vectorstores"] 5267c032_dda3_79c4_9c44_828c1765ed44 --> f75e66a0_314a_f961_16d7_464ee959064b dd5e7909_a646_84f1_497b_cae69735550e["pydantic"] 5267c032_dda3_79c4_9c44_828c1765ed44 --> dd5e7909_a646_84f1_497b_cae69735550e a4aca3cb_d354_1b6d_bde6_2a56d12c755c["langchain_community.tools.vectorstore.tool"] 5267c032_dda3_79c4_9c44_828c1765ed44 --> a4aca3cb_d354_1b6d_bde6_2a56d12c755c style 5267c032_dda3_79c4_9c44_828c1765ed44 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Toolkit for interacting with a vector store."""
from langchain_core.language_models import BaseLanguageModel
from langchain_core.tools import BaseTool
from langchain_core.tools.base import BaseToolkit
from langchain_core.vectorstores import VectorStore
from pydantic import BaseModel, ConfigDict, Field
class VectorStoreInfo(BaseModel):
"""Information about a `VectorStore`."""
vectorstore: VectorStore = Field(exclude=True)
name: str
description: str
model_config = ConfigDict(
arbitrary_types_allowed=True,
)
class VectorStoreToolkit(BaseToolkit):
"""Toolkit for interacting with a `VectorStore`."""
vectorstore_info: VectorStoreInfo = Field(exclude=True)
llm: BaseLanguageModel
model_config = ConfigDict(
arbitrary_types_allowed=True,
)
def get_tools(self) -> list[BaseTool]:
"""Get the tools in the toolkit."""
try:
from langchain_community.tools.vectorstore.tool import (
VectorStoreQATool,
VectorStoreQAWithSourcesTool,
)
except ImportError as e:
msg = "You need to install langchain-community to use this toolkit."
raise ImportError(msg) from e
description = VectorStoreQATool.get_description(
self.vectorstore_info.name,
self.vectorstore_info.description,
)
qa_tool = VectorStoreQATool(
name=self.vectorstore_info.name,
description=description,
vectorstore=self.vectorstore_info.vectorstore,
llm=self.llm,
)
description = VectorStoreQAWithSourcesTool.get_description(
self.vectorstore_info.name,
self.vectorstore_info.description,
)
qa_with_sources_tool = VectorStoreQAWithSourcesTool(
name=f"{self.vectorstore_info.name}_with_sources",
description=description,
vectorstore=self.vectorstore_info.vectorstore,
llm=self.llm,
)
return [qa_tool, qa_with_sources_tool]
class VectorStoreRouterToolkit(BaseToolkit):
"""Toolkit for routing between Vector Stores."""
vectorstores: list[VectorStoreInfo] = Field(exclude=True)
llm: BaseLanguageModel
model_config = ConfigDict(
arbitrary_types_allowed=True,
)
def get_tools(self) -> list[BaseTool]:
"""Get the tools in the toolkit."""
tools: list[BaseTool] = []
try:
from langchain_community.tools.vectorstore.tool import (
VectorStoreQATool,
)
except ImportError as e:
msg = "You need to install langchain-community to use this toolkit."
raise ImportError(msg) from e
for vectorstore_info in self.vectorstores:
description = VectorStoreQATool.get_description(
vectorstore_info.name,
vectorstore_info.description,
)
qa_tool = VectorStoreQATool(
name=vectorstore_info.name,
description=description,
vectorstore=vectorstore_info.vectorstore,
llm=self.llm,
)
tools.append(qa_tool)
return tools
Domain
Subdomains
Dependencies
- langchain_community.tools.vectorstore.tool
- langchain_core.language_models
- langchain_core.tools
- langchain_core.tools.base
- langchain_core.vectorstores
- pydantic
Source
Frequently Asked Questions
What does toolkit.py do?
toolkit.py is a source file in the langchain codebase, written in python. It belongs to the AgentOrchestration domain, AgentExcecutor subdomain.
What does toolkit.py depend on?
toolkit.py imports 6 module(s): langchain_community.tools.vectorstore.tool, langchain_core.language_models, langchain_core.tools, langchain_core.tools.base, langchain_core.vectorstores, pydantic.
Where is toolkit.py in the architecture?
toolkit.py is located at libs/langchain/langchain_classic/agents/agent_toolkits/vectorstore/toolkit.py (domain: AgentOrchestration, subdomain: AgentExcecutor, directory: libs/langchain/langchain_classic/agents/agent_toolkits/vectorstore).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free