convert.py — langchain Source File
Architecture documentation for convert.py, a python file in the langchain codebase. 9 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 6e48690f_ba38_f154_c479_86fd0c4ec707["convert.py"] 589b2e2f_c593_ed0a_7906_df4ca371d542["inspect"] 6e48690f_ba38_f154_c479_86fd0c4ec707 --> 589b2e2f_c593_ed0a_7906_df4ca371d542 2bf6d401_816d_d011_3b05_a6114f55ff58["collections.abc"] 6e48690f_ba38_f154_c479_86fd0c4ec707 --> 2bf6d401_816d_d011_3b05_a6114f55ff58 feec1ec4_6917_867b_d228_b134d0ff8099["typing"] 6e48690f_ba38_f154_c479_86fd0c4ec707 --> feec1ec4_6917_867b_d228_b134d0ff8099 dd5e7909_a646_84f1_497b_cae69735550e["pydantic"] 6e48690f_ba38_f154_c479_86fd0c4ec707 --> dd5e7909_a646_84f1_497b_cae69735550e 17a62cb3_fefd_6320_b757_b53bb4a1c661["langchain_core.callbacks"] 6e48690f_ba38_f154_c479_86fd0c4ec707 --> 17a62cb3_fefd_6320_b757_b53bb4a1c661 31eab4ab_7281_1e6c_b17d_12e6ad9de07a["langchain_core.runnables"] 6e48690f_ba38_f154_c479_86fd0c4ec707 --> 31eab4ab_7281_1e6c_b17d_12e6ad9de07a 95e05501_5650_2f3c_99db_c054e96d4e43["langchain_core.tools.base"] 6e48690f_ba38_f154_c479_86fd0c4ec707 --> 95e05501_5650_2f3c_99db_c054e96d4e43 6c1f3453_15c8_69b5_fa21_6ba7f4b2a19e["langchain_core.tools.simple"] 6e48690f_ba38_f154_c479_86fd0c4ec707 --> 6c1f3453_15c8_69b5_fa21_6ba7f4b2a19e f9a93d82_34e2_cfc5_13e6_36b4bde68507["langchain_core.tools.structured"] 6e48690f_ba38_f154_c479_86fd0c4ec707 --> f9a93d82_34e2_cfc5_13e6_36b4bde68507 style 6e48690f_ba38_f154_c479_86fd0c4ec707 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Convert functions and runnables to tools."""
import inspect
from collections.abc import Callable
from typing import Any, Literal, cast, get_type_hints, overload
from pydantic import BaseModel, Field, create_model
from langchain_core.callbacks import Callbacks
from langchain_core.runnables import Runnable
from langchain_core.tools.base import ArgsSchema, BaseTool
from langchain_core.tools.simple import Tool
from langchain_core.tools.structured import StructuredTool
@overload
def tool(
*,
description: str | None = None,
return_direct: bool = False,
args_schema: ArgsSchema | None = None,
infer_schema: bool = True,
response_format: Literal["content", "content_and_artifact"] = "content",
parse_docstring: bool = False,
error_on_invalid_docstring: bool = True,
extras: dict[str, Any] | None = None,
) -> Callable[[Callable | Runnable], BaseTool]: ...
@overload
def tool(
name_or_callable: str,
runnable: Runnable,
*,
description: str | None = None,
return_direct: bool = False,
args_schema: ArgsSchema | None = None,
infer_schema: bool = True,
response_format: Literal["content", "content_and_artifact"] = "content",
parse_docstring: bool = False,
error_on_invalid_docstring: bool = True,
extras: dict[str, Any] | None = None,
) -> BaseTool: ...
@overload
def tool(
name_or_callable: Callable,
*,
description: str | None = None,
return_direct: bool = False,
args_schema: ArgsSchema | None = None,
infer_schema: bool = True,
response_format: Literal["content", "content_and_artifact"] = "content",
parse_docstring: bool = False,
error_on_invalid_docstring: bool = True,
extras: dict[str, Any] | None = None,
) -> BaseTool: ...
// ... (417 more lines)
Domain
Subdomains
Functions
Dependencies
- collections.abc
- inspect
- langchain_core.callbacks
- langchain_core.runnables
- langchain_core.tools.base
- langchain_core.tools.simple
- langchain_core.tools.structured
- pydantic
- typing
Source
Frequently Asked Questions
What does convert.py do?
convert.py is a source file in the langchain codebase, written in python. It belongs to the LangChainCore domain, MessageInterface subdomain.
What functions are defined in convert.py?
convert.py defines 4 function(s): _get_description_from_runnable, _get_schema_from_runnable_and_arg_types, convert_runnable_to_tool, tool.
What does convert.py depend on?
convert.py imports 9 module(s): collections.abc, inspect, langchain_core.callbacks, langchain_core.runnables, langchain_core.tools.base, langchain_core.tools.simple, langchain_core.tools.structured, pydantic, and 1 more.
Where is convert.py in the architecture?
convert.py is located at libs/core/langchain_core/tools/convert.py (domain: LangChainCore, subdomain: MessageInterface, directory: libs/core/langchain_core/tools).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free