test_generate_response_from_error_with_valid_json() — langchain Function Reference
Architecture documentation for the test_generate_response_from_error_with_valid_json() function in test_base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 48c6974d_8545_2684_331e_e24438f054a4["test_generate_response_from_error_with_valid_json()"] 8830054d_ac1e_daa9_c6c5_ff55b10d0bf3["test_base.py"] 48c6974d_8545_2684_331e_e24438f054a4 -->|defined in| 8830054d_ac1e_daa9_c6c5_ff55b10d0bf3 style 48c6974d_8545_2684_331e_e24438f054a4 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/language_models/chat_models/test_base.py lines 1267–1289
def test_generate_response_from_error_with_valid_json() -> None:
"""Test `_generate_response_from_error` with valid JSON response."""
response = MockResponse(
status_code=400,
headers={"content-type": "application/json"},
json_data={"error": {"message": "Bad request", "type": "invalid_request"}},
)
error = MockAPIError("API Error", response=response)
generations = _generate_response_from_error(error)
assert len(generations) == 1
generation = generations[0]
assert isinstance(generation, ChatGeneration)
assert isinstance(generation.message, AIMessage)
assert generation.message.content == ""
metadata = generation.message.response_metadata
assert metadata["body"] == {
"error": {"message": "Bad request", "type": "invalid_request"}
}
assert metadata["headers"] == {"content-type": "application/json"}
assert metadata["status_code"] == 400
Domain
Subdomains
Source
Frequently Asked Questions
What does test_generate_response_from_error_with_valid_json() do?
test_generate_response_from_error_with_valid_json() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/language_models/chat_models/test_base.py.
Where is test_generate_response_from_error_with_valid_json() defined?
test_generate_response_from_error_with_valid_json() is defined in libs/core/tests/unit_tests/language_models/chat_models/test_base.py at line 1267.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free