test_openai_structured_output_refusal_handling_responses_api() — langchain Function Reference
Architecture documentation for the test_openai_structured_output_refusal_handling_responses_api() function in test_base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD da16ce4f_53dd_0b18_b574_3d381497135b["test_openai_structured_output_refusal_handling_responses_api()"] 48232d20_f8c1_b597_14fa_7dc407e9bfe5["test_base.py"] da16ce4f_53dd_0b18_b574_3d381497135b -->|defined in| 48232d20_f8c1_b597_14fa_7dc407e9bfe5 style da16ce4f_53dd_0b18_b574_3d381497135b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/openai/tests/unit_tests/chat_models/test_base.py lines 3204–3235
def test_openai_structured_output_refusal_handling_responses_api() -> None:
"""
Test that _oai_structured_outputs_parser raises OpenAIRefusalError
when the AIMessage contains a refusal block from OpenAI's Responses API.
"""
ai_msg = AIMessage(
content=[
{
"id": "rs_fake_id",
"summary": [],
"type": "reasoning",
"encrypted_content": "fake_encrypted_content",
},
{
"type": "refusal",
"refusal": "refused content in string",
"id": "msg_fake_id",
},
],
)
# schema does not matter in this issue
class MySchema(BaseModel):
foo: int
try:
_oai_structured_outputs_parser(ai_msg, MySchema)
except OpenAIRefusalError:
# OpenAIRefusalError was raised. This is the proper behavior.
pass
except ValueError as e:
pytest.fail(f"This is a wrong behavior. Error details: {e}")
Domain
Subdomains
Source
Frequently Asked Questions
What does test_openai_structured_output_refusal_handling_responses_api() do?
test_openai_structured_output_refusal_handling_responses_api() is a function in the langchain codebase, defined in libs/partners/openai/tests/unit_tests/chat_models/test_base.py.
Where is test_openai_structured_output_refusal_handling_responses_api() defined?
test_openai_structured_output_refusal_handling_responses_api() is defined in libs/partners/openai/tests/unit_tests/chat_models/test_base.py at line 3204.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free