Home / Function/ _get_schema_from_runnable_and_arg_types() — langchain Function Reference

_get_schema_from_runnable_and_arg_types() — langchain Function Reference

Architecture documentation for the _get_schema_from_runnable_and_arg_types() function in convert.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  1734c01b_3c56_2760_c792_a550f26b661a["_get_schema_from_runnable_and_arg_types()"]
  6e48690f_ba38_f154_c479_86fd0c4ec707["convert.py"]
  1734c01b_3c56_2760_c792_a550f26b661a -->|defined in| 6e48690f_ba38_f154_c479_86fd0c4ec707
  9a0bf2ef_bf97_2fbb_77da_f7816cedcfef["convert_runnable_to_tool()"]
  9a0bf2ef_bf97_2fbb_77da_f7816cedcfef -->|calls| 1734c01b_3c56_2760_c792_a550f26b661a
  style 1734c01b_3c56_2760_c792_a550f26b661a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/tools/convert.py lines 399–416

def _get_schema_from_runnable_and_arg_types(
    runnable: Runnable,
    name: str,
    arg_types: dict[str, type] | None = None,
) -> type[BaseModel]:
    """Infer `args_schema` for tool."""
    if arg_types is None:
        try:
            arg_types = get_type_hints(runnable.InputType)
        except TypeError as e:
            msg = (
                "Tool input must be str or dict. If dict, dict arguments must be "
                "typed. Either annotate types (e.g., with TypedDict) or pass "
                f"arg_types into `.as_tool` to specify. {e}"
            )
            raise TypeError(msg) from e
    fields = {key: (key_type, Field(...)) for key, key_type in arg_types.items()}
    return cast("type[BaseModel]", create_model(name, **fields))  # type: ignore[call-overload]

Domain

Subdomains

Frequently Asked Questions

What does _get_schema_from_runnable_and_arg_types() do?
_get_schema_from_runnable_and_arg_types() is a function in the langchain codebase, defined in libs/core/langchain_core/tools/convert.py.
Where is _get_schema_from_runnable_and_arg_types() defined?
_get_schema_from_runnable_and_arg_types() is defined in libs/core/langchain_core/tools/convert.py at line 399.
What calls _get_schema_from_runnable_and_arg_types()?
_get_schema_from_runnable_and_arg_types() is called by 1 function(s): convert_runnable_to_tool.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free