Home / File/ test_json.py — langchain Source File

test_json.py — langchain Source File

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

File python CoreAbstractions RunnableInterface 10 imports 16 functions 2 classes

Entity Profile

Dependency Diagram

graph LR
  8edb1db9_86b9_7cd9_158b_8b5423c9a6dd["test_json.py"]
  7025b240_fdc3_cf68_b72f_f41dac94566b["json"]
  8edb1db9_86b9_7cd9_158b_8b5423c9a6dd --> 7025b240_fdc3_cf68_b72f_f41dac94566b
  cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7["collections.abc"]
  8edb1db9_86b9_7cd9_158b_8b5423c9a6dd --> cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7
  8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"]
  8edb1db9_86b9_7cd9_158b_8b5423c9a6dd --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3
  120e2591_3e15_b895_72b6_cb26195e40a6["pytest"]
  8edb1db9_86b9_7cd9_158b_8b5423c9a6dd --> 120e2591_3e15_b895_72b6_cb26195e40a6
  6e58aaea_f08e_c099_3cc7_f9567bfb1ae7["pydantic"]
  8edb1db9_86b9_7cd9_158b_8b5423c9a6dd --> 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7
  75137834_4ba7_dc43_7ec5_182c05eceedf["langchain_core.exceptions"]
  8edb1db9_86b9_7cd9_158b_8b5423c9a6dd --> 75137834_4ba7_dc43_7ec5_182c05eceedf
  d45ff838_1238_0965_d3b7_5b33a0452ec0["langchain_core.output_parsers.json"]
  8edb1db9_86b9_7cd9_158b_8b5423c9a6dd --> d45ff838_1238_0965_d3b7_5b33a0452ec0
  a6f93333_6d02_5473_677b_843422594588["langchain_core.utils.function_calling"]
  8edb1db9_86b9_7cd9_158b_8b5423c9a6dd --> a6f93333_6d02_5473_677b_843422594588
  78c5ca66_f675_3ca1_fdb7_d5a994dcf4bf["langchain_core.utils.json"]
  8edb1db9_86b9_7cd9_158b_8b5423c9a6dd --> 78c5ca66_f675_3ca1_fdb7_d5a994dcf4bf
  0c2180a7_0be1_b691_e68d_3d66de6d36e9["tests.unit_tests.pydantic_utils"]
  8edb1db9_86b9_7cd9_158b_8b5423c9a6dd --> 0c2180a7_0be1_b691_e68d_3d66de6d36e9
  style 8edb1db9_86b9_7cd9_158b_8b5423c9a6dd fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import json
from collections.abc import AsyncIterator, Iterator
from typing import Any

import pytest
from pydantic import BaseModel, Field

from langchain_core.exceptions import OutputParserException
from langchain_core.output_parsers.json import (
    SimpleJsonOutputParser,
)
from langchain_core.utils.function_calling import convert_to_openai_function
from langchain_core.utils.json import (
    parse_and_check_json_markdown,
    parse_json_markdown,
    parse_partial_json,
)
from tests.unit_tests.pydantic_utils import _schema

GOOD_JSON = """```json
{
    "foo": "bar"
}
```"""

JSON_WITH_NEW_LINES = """

```json
{
    "foo": "bar"
}
```

"""

JSON_WITH_NEW_LINES_INSIDE = """```json
{

    "foo": "bar"

}
```"""

JSON_WITH_NEW_LINES_EVERYWHERE = """

```json

{

    "foo": "bar"

}

```

"""

TICKS_WITH_NEW_LINES_EVERYWHERE = """

```
// ... (571 more lines)

Subdomains

Classes

Dependencies

  • collections.abc
  • json
  • langchain_core.exceptions
  • langchain_core.output_parsers.json
  • langchain_core.utils.function_calling
  • langchain_core.utils.json
  • pydantic
  • pytest
  • tests.unit_tests.pydantic_utils
  • typing

Frequently Asked Questions

What does test_json.py do?
test_json.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, RunnableInterface subdomain.
What functions are defined in test_json.py?
test_json.py defines 16 function(s): test_base_model_schema_consistency, test_parse_json, test_parse_json_with_code_blocks, test_parse_json_with_code_blocks_and_newlines, test_parse_json_with_part_code_blocks, test_parse_json_with_python_dict, test_parse_nested_json_with_escaped_quotes, test_parse_non_dict_json_output, test_parse_partial_json, test_partial_text_json_output_parser, and 6 more.
What does test_json.py depend on?
test_json.py imports 10 module(s): collections.abc, json, langchain_core.exceptions, langchain_core.output_parsers.json, langchain_core.utils.function_calling, langchain_core.utils.json, pydantic, pytest, and 2 more.
Where is test_json.py in the architecture?
test_json.py is located at libs/core/tests/unit_tests/output_parsers/test_json.py (domain: CoreAbstractions, subdomain: RunnableInterface, directory: libs/core/tests/unit_tests/output_parsers).

Analyze Your Own Codebase

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

Try Supermodel Free