Home / File/ test_json_schema.py — langchain Source File

test_json_schema.py — langchain Source File

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

File python LangChainCore ApiManagement 7 imports 22 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  5d9c8eae_7a4a_0ffa_fa7c_a89825bcf1fa["test_json_schema.py"]
  7ec08df6_88bd_07ab_d50f_0d4c4e429b7e["enum"]
  5d9c8eae_7a4a_0ffa_fa7c_a89825bcf1fa --> 7ec08df6_88bd_07ab_d50f_0d4c4e429b7e
  dd5e7909_a646_84f1_497b_cae69735550e["pydantic"]
  5d9c8eae_7a4a_0ffa_fa7c_a89825bcf1fa --> dd5e7909_a646_84f1_497b_cae69735550e
  f69d6389_263d_68a4_7fbf_f14c0602a9ba["pytest"]
  5d9c8eae_7a4a_0ffa_fa7c_a89825bcf1fa --> f69d6389_263d_68a4_7fbf_f14c0602a9ba
  2afbf5d5_989b_4b80_c3b6_e197c3c19574["packaging.version"]
  5d9c8eae_7a4a_0ffa_fa7c_a89825bcf1fa --> 2afbf5d5_989b_4b80_c3b6_e197c3c19574
  121262a1_0bd6_d637_bce3_307ab6b3ecd4["langchain_core.tools"]
  5d9c8eae_7a4a_0ffa_fa7c_a89825bcf1fa --> 121262a1_0bd6_d637_bce3_307ab6b3ecd4
  5c738c12_cc4f_cee1_0e1d_562012a5f844["langchain_core.utils.function_calling"]
  5d9c8eae_7a4a_0ffa_fa7c_a89825bcf1fa --> 5c738c12_cc4f_cee1_0e1d_562012a5f844
  40187213_b27b_e0e5_3af5_355e417dcd92["langchain_core.utils.json_schema"]
  5d9c8eae_7a4a_0ffa_fa7c_a89825bcf1fa --> 40187213_b27b_e0e5_3af5_355e417dcd92
  style 5d9c8eae_7a4a_0ffa_fa7c_a89825bcf1fa fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from enum import Enum

import pydantic
import pytest
from packaging.version import Version

from langchain_core.tools import tool
from langchain_core.utils.function_calling import convert_to_openai_tool
from langchain_core.utils.json_schema import dereference_refs


def test_dereference_refs_no_refs() -> None:
    schema = {
        "type": "object",
        "properties": {
            "first_name": {"type": "string"},
        },
    }
    actual = dereference_refs(schema)
    assert actual == schema


def test_dereference_refs_one_ref() -> None:
    schema = {
        "type": "object",
        "properties": {
            "first_name": {"$ref": "#/$defs/name"},
        },
        "$defs": {"name": {"type": "string"}},
    }
    expected = {
        "type": "object",
        "properties": {
            "first_name": {"type": "string"},
        },
        "$defs": {"name": {"type": "string"}},
    }
    actual = dereference_refs(schema)
    assert actual == expected


def test_dereference_refs_multiple_refs() -> None:
    schema = {
        "type": "object",
        "properties": {
            "first_name": {"$ref": "#/$defs/name"},
            "other": {"$ref": "#/$defs/other"},
        },
        "$defs": {
            "name": {"type": "string"},
            "other": {"type": "object", "properties": {"age": "int", "height": "int"}},
        },
    }
    expected = {
        "type": "object",
        "properties": {
            "first_name": {"type": "string"},
            "other": {"type": "object", "properties": {"age": "int", "height": "int"}},
        },
        "$defs": {
// ... (847 more lines)

Domain

Subdomains

Classes

Dependencies

  • enum
  • langchain_core.tools
  • langchain_core.utils.function_calling
  • langchain_core.utils.json_schema
  • packaging.version
  • pydantic
  • pytest

Frequently Asked Questions

What does test_json_schema.py do?
test_json_schema.py is a source file in the langchain codebase, written in python. It belongs to the LangChainCore domain, ApiManagement subdomain.
What functions are defined in test_json_schema.py?
test_json_schema.py defines 22 function(s): test_convert_to_openai_tool_preserves_enum_defaults, test_dereference_refs_array_with_mixed_refs, test_dereference_refs_complex_pattern, test_dereference_refs_cyclical_mixed_refs, test_dereference_refs_cyclical_refs, test_dereference_refs_empty_mixed_ref, test_dereference_refs_integer_ref, test_dereference_refs_list_index, test_dereference_refs_list_index_items_ref_mcp_like, test_dereference_refs_missing_ref, and 12 more.
What does test_json_schema.py depend on?
test_json_schema.py imports 7 module(s): enum, langchain_core.tools, langchain_core.utils.function_calling, langchain_core.utils.json_schema, packaging.version, pydantic, pytest.
Where is test_json_schema.py in the architecture?
test_json_schema.py is located at libs/core/tests/unit_tests/utils/test_json_schema.py (domain: LangChainCore, subdomain: ApiManagement, directory: libs/core/tests/unit_tests/utils).

Analyze Your Own Codebase

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

Try Supermodel Free