Home / File/ utils.py — langchain Source File

utils.py — langchain Source File

Architecture documentation for utils.py, a python file in the langchain codebase. 5 imports, 0 dependents.

File python LangChainCore Runnables 5 imports 1 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  aaaa64a3_6aaa_e56e_ad70_bb784e2fbe3f["utils.py"]
  9d14ea65_8b2e_6721_a947_acc89905651f["json"]
  aaaa64a3_6aaa_e56e_ad70_bb784e2fbe3f --> 9d14ea65_8b2e_6721_a947_acc89905651f
  927570d8_11a6_5c17_0f0d_80baae0c733e["pathlib"]
  aaaa64a3_6aaa_e56e_ad70_bb784e2fbe3f --> 927570d8_11a6_5c17_0f0d_80baae0c733e
  feec1ec4_6917_867b_d228_b134d0ff8099["typing"]
  aaaa64a3_6aaa_e56e_ad70_bb784e2fbe3f --> feec1ec4_6917_867b_d228_b134d0ff8099
  dd5e7909_a646_84f1_497b_cae69735550e["pydantic"]
  aaaa64a3_6aaa_e56e_ad70_bb784e2fbe3f --> dd5e7909_a646_84f1_497b_cae69735550e
  80ba36ba_4e37_50f9_f413_5797ec5cd588["pydantic.alias_generators"]
  aaaa64a3_6aaa_e56e_ad70_bb784e2fbe3f --> 80ba36ba_4e37_50f9_f413_5797ec5cd588
  style aaaa64a3_6aaa_e56e_ad70_bb784e2fbe3f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import json
from pathlib import Path
from typing import TypeVar

from pydantic import BaseModel, ConfigDict
from pydantic.alias_generators import to_camel


class BaseSchema(BaseModel):
    model_config = ConfigDict(
        alias_generator=to_camel,
        populate_by_name=True,
        from_attributes=True,
    )


_T = TypeVar("_T", bound=BaseModel)


def load_spec(spec_name: str, as_model: type[_T]) -> list[_T]:
    with (Path(__file__).parent / "specifications" / f"{spec_name}.json").open(
        "r", encoding="utf-8"
    ) as f:
        data = json.load(f)
        return [as_model(**item) for item in data]

Domain

Subdomains

Functions

Classes

Dependencies

  • json
  • pathlib
  • pydantic
  • pydantic.alias_generators
  • typing

Frequently Asked Questions

What does utils.py do?
utils.py is a source file in the langchain codebase, written in python. It belongs to the LangChainCore domain, Runnables subdomain.
What functions are defined in utils.py?
utils.py defines 1 function(s): load_spec.
What does utils.py depend on?
utils.py imports 5 module(s): json, pathlib, pydantic, pydantic.alias_generators, typing.
Where is utils.py in the architecture?
utils.py is located at libs/langchain_v1/tests/unit_tests/agents/utils.py (domain: LangChainCore, subdomain: Runnables, directory: libs/langchain_v1/tests/unit_tests/agents).

Analyze Your Own Codebase

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

Try Supermodel Free