Home / Class/ TestOpenAIResponses Class — langchain Architecture

TestOpenAIResponses Class — langchain Architecture

Architecture documentation for the TestOpenAIResponses class in test_responses_standard.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  25cafc0a_8f3b_2d49_7e58_88f79aca1167["TestOpenAIResponses"]
  59b2cda2_7dec_b2fd_a101_d5afcda5ed66["TestOpenAIStandard"]
  25cafc0a_8f3b_2d49_7e58_88f79aca1167 -->|extends| 59b2cda2_7dec_b2fd_a101_d5afcda5ed66
  cf462a1a_46c7_84ad_3ab6_db148c0ffcc0["test_responses_standard.py"]
  25cafc0a_8f3b_2d49_7e58_88f79aca1167 -->|defined in| cf462a1a_46c7_84ad_3ab6_db148c0ffcc0
  24467b9d_cf72_7c8f_908f_f20ed888aece["chat_model_class()"]
  25cafc0a_8f3b_2d49_7e58_88f79aca1167 -->|method| 24467b9d_cf72_7c8f_908f_f20ed888aece
  47c3ac28_01be_1cfb_378d_4ddb8b1d9c39["chat_model_params()"]
  25cafc0a_8f3b_2d49_7e58_88f79aca1167 -->|method| 47c3ac28_01be_1cfb_378d_4ddb8b1d9c39
  e7319265_5d8b_2fb7_6397_60c7aa2ef365["supports_image_tool_message()"]
  25cafc0a_8f3b_2d49_7e58_88f79aca1167 -->|method| e7319265_5d8b_2fb7_6397_60c7aa2ef365
  0eac7b08_dec6_da2a_e33b_9de7d583874c["test_stop_sequence()"]
  25cafc0a_8f3b_2d49_7e58_88f79aca1167 -->|method| 0eac7b08_dec6_da2a_e33b_9de7d583874c
  f94ea83b_6f8c_3303_ea07_185c3e5ae19d["invoke_with_cache_read_input()"]
  25cafc0a_8f3b_2d49_7e58_88f79aca1167 -->|method| f94ea83b_6f8c_3303_ea07_185c3e5ae19d
  59088497_61be_dc54_ef74_dbec3fa4367e["invoke_with_reasoning_output()"]
  25cafc0a_8f3b_2d49_7e58_88f79aca1167 -->|method| 59088497_61be_dc54_ef74_dbec3fa4367e
  a80cbf5d_8d5f_81e7_c681_adc8bbeced2a["test_openai_pdf_inputs()"]
  25cafc0a_8f3b_2d49_7e58_88f79aca1167 -->|method| a80cbf5d_8d5f_81e7_c681_adc8bbeced2a
  8fca2012_4028_c94e_2716_ac06586083e0["supports_pdf_tool_message()"]
  25cafc0a_8f3b_2d49_7e58_88f79aca1167 -->|method| 8fca2012_4028_c94e_2716_ac06586083e0
  19509b4b_da10_d2cd_31b9_8ced23add686["test_openai_pdf_tool_messages()"]
  25cafc0a_8f3b_2d49_7e58_88f79aca1167 -->|method| 19509b4b_da10_d2cd_31b9_8ced23add686

Relationship Graph

Source Code

libs/partners/openai/tests/integration_tests/chat_models/test_responses_standard.py lines 18–127

class TestOpenAIResponses(TestOpenAIStandard):
    @property
    def chat_model_class(self) -> type[BaseChatModel]:
        return ChatOpenAI

    @property
    def chat_model_params(self) -> dict:
        return {"model": "gpt-4o-mini", "use_responses_api": True}

    @property
    def supports_image_tool_message(self) -> bool:
        return True

    @pytest.mark.xfail(reason="Unsupported.")
    def test_stop_sequence(self, model: BaseChatModel) -> None:
        super().test_stop_sequence(model)

    def invoke_with_cache_read_input(self, *, stream: bool = False) -> AIMessage:
        with Path.open(REPO_ROOT_DIR / "README.md") as f:
            readme = f.read()

        input_ = f"""What's langchain? Here's the langchain README:

        {readme}
        """
        llm = ChatOpenAI(model="gpt-4.1-mini", use_responses_api=True)
        _invoke(llm, input_, stream)
        # invoke twice so first invocation is cached
        return _invoke(llm, input_, stream)

    def invoke_with_reasoning_output(self, *, stream: bool = False) -> AIMessage:
        llm = ChatOpenAI(
            model="o4-mini",
            reasoning={"effort": "medium", "summary": "auto"},
            use_responses_api=True,
        )
        input_ = "What was the 3rd highest building in 2000?"
        return _invoke(llm, input_, stream)

    @pytest.mark.flaky(retries=3, delay=1)
    def test_openai_pdf_inputs(self, model: BaseChatModel) -> None:
        """Test that the model can process PDF inputs."""
        super().test_openai_pdf_inputs(model)
        # Responses API additionally supports files via URL
        url = "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"

        message = HumanMessage(
            [
                {"type": "text", "text": "What is the document title, verbatim?"},
                {"type": "file", "url": url},
            ]
        )
        _ = model.invoke([message])

        # Test OpenAI Responses format
        message = HumanMessage(
            [
                {"type": "text", "text": "What is the document title, verbatim?"},
                {"type": "input_file", "file_url": url},
            ]
        )
        _ = model.invoke([message])

    @property
    def supports_pdf_tool_message(self) -> bool:
        # OpenAI requires a filename for PDF inputs
        # For now, we test with filename in OpenAI-specific tests
        return False

    def test_openai_pdf_tool_messages(self, model: BaseChatModel) -> None:
        """Test that the model can process PDF inputs in `ToolMessage` objects."""
        url = "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
        pdf_data = base64.b64encode(httpx.get(url).content).decode("utf-8")

        tool_message = ToolMessage(
            content_blocks=[
                {
                    "type": "file",
                    "base64": pdf_data,
                    "mime_type": "application/pdf",
                    "extras": {"filename": "my-pdf"},  # specify filename

Frequently Asked Questions

What is the TestOpenAIResponses class?
TestOpenAIResponses is a class in the langchain codebase, defined in libs/partners/openai/tests/integration_tests/chat_models/test_responses_standard.py.
Where is TestOpenAIResponses defined?
TestOpenAIResponses is defined in libs/partners/openai/tests/integration_tests/chat_models/test_responses_standard.py at line 18.
What does TestOpenAIResponses extend?
TestOpenAIResponses extends TestOpenAIStandard.

Analyze Your Own Codebase

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

Try Supermodel Free