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. 2 imports, 0 dependents.

File python LangChainCore MessageInterface 2 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  67815222_b543_3a57_2b15_f724f1404204["test_json.py"]
  59e0d3b0_0f8e_4b79_d442_e9b4821561c7["langchain_core.agents"]
  67815222_b543_3a57_2b15_f724f1404204 --> 59e0d3b0_0f8e_4b79_d442_e9b4821561c7
  048ded1e_97b7_15b1_6540_0fae90ffb8d1["langchain_classic.agents.output_parsers.json"]
  67815222_b543_3a57_2b15_f724f1404204 --> 048ded1e_97b7_15b1_6540_0fae90ffb8d1
  style 67815222_b543_3a57_2b15_f724f1404204 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from langchain_core.agents import AgentAction, AgentFinish

from langchain_classic.agents.output_parsers.json import JSONAgentOutputParser


def test_tool_usage() -> None:
    parser = JSONAgentOutputParser()
    _input = """    ```
{
  "action": "search",
  "action_input": "2+2"
}
```"""
    output = parser.invoke(_input)
    expected_output = AgentAction(tool="search", tool_input="2+2", log=_input)
    assert output == expected_output


def test_finish() -> None:
    parser = JSONAgentOutputParser()
    _input = """```
{
  "action": "Final Answer",
  "action_input": "4"
}
```"""
    output = parser.invoke(_input)
    expected_output = AgentFinish(return_values={"output": "4"}, log=_input)
    assert output == expected_output

Domain

Subdomains

Dependencies

  • langchain_classic.agents.output_parsers.json
  • langchain_core.agents

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 LangChainCore domain, MessageInterface subdomain.
What functions are defined in test_json.py?
test_json.py defines 2 function(s): test_finish, test_tool_usage.
What does test_json.py depend on?
test_json.py imports 2 module(s): langchain_classic.agents.output_parsers.json, langchain_core.agents.
Where is test_json.py in the architecture?
test_json.py is located at libs/langchain/tests/unit_tests/agents/output_parsers/test_json.py (domain: LangChainCore, subdomain: MessageInterface, directory: libs/langchain/tests/unit_tests/agents/output_parsers).

Analyze Your Own Codebase

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

Try Supermodel Free