Home / Class/ TestOpenAIStandard Class — langchain Architecture

TestOpenAIStandard Class — langchain Architecture

Architecture documentation for the TestOpenAIStandard class in test_base_standard.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  7abe9b90_e935_0a24_a895_1fdedde76d15["TestOpenAIStandard"]
  82a73afa_4570_e4e0_ee0b_cee9788da0b5["ChatModelIntegrationTests"]
  7abe9b90_e935_0a24_a895_1fdedde76d15 -->|extends| 82a73afa_4570_e4e0_ee0b_cee9788da0b5
  2b842419_0065_4f83_a358_908517775dea["test_base_standard.py"]
  7abe9b90_e935_0a24_a895_1fdedde76d15 -->|defined in| 2b842419_0065_4f83_a358_908517775dea
  5b468f13_77ef_6647_7abf_91b539952123["chat_model_class()"]
  7abe9b90_e935_0a24_a895_1fdedde76d15 -->|method| 5b468f13_77ef_6647_7abf_91b539952123
  de91c232_e2cc_2f7f_c3ad_c24a3dece16d["chat_model_params()"]
  7abe9b90_e935_0a24_a895_1fdedde76d15 -->|method| de91c232_e2cc_2f7f_c3ad_c24a3dece16d
  d7b4840d_635d_6a7b_5069_0552b011c632["supports_image_inputs()"]
  7abe9b90_e935_0a24_a895_1fdedde76d15 -->|method| d7b4840d_635d_6a7b_5069_0552b011c632
  17e6dad8_3702_b304_d29b_aae024581995["supports_image_urls()"]
  7abe9b90_e935_0a24_a895_1fdedde76d15 -->|method| 17e6dad8_3702_b304_d29b_aae024581995
  2fe3f8a9_291e_aa93_229a_9bbb7de13747["supports_json_mode()"]
  7abe9b90_e935_0a24_a895_1fdedde76d15 -->|method| 2fe3f8a9_291e_aa93_229a_9bbb7de13747
  c7a02995_b80f_3df1_facb_6a18dbb91b09["supports_anthropic_inputs()"]
  7abe9b90_e935_0a24_a895_1fdedde76d15 -->|method| c7a02995_b80f_3df1_facb_6a18dbb91b09
  2314ffc0_129a_99a9_bc16_3bb748fa3c4f["supported_usage_metadata_details()"]
  7abe9b90_e935_0a24_a895_1fdedde76d15 -->|method| 2314ffc0_129a_99a9_bc16_3bb748fa3c4f
  e859e4c0_bcf0_5389_daee_66de3947e0a7["enable_vcr_tests()"]
  7abe9b90_e935_0a24_a895_1fdedde76d15 -->|method| e859e4c0_bcf0_5389_daee_66de3947e0a7
  1a67c139_ea36_e5ff_9ded_fdeb38fcb3af["invoke_with_cache_read_input()"]
  7abe9b90_e935_0a24_a895_1fdedde76d15 -->|method| 1a67c139_ea36_e5ff_9ded_fdeb38fcb3af
  283acc53_bacb_4872_3e74_becd101d2b3d["invoke_with_reasoning_output()"]
  7abe9b90_e935_0a24_a895_1fdedde76d15 -->|method| 283acc53_bacb_4872_3e74_becd101d2b3d
  6ad9fe16_7cf5_e819_4a9e_84239c16c80c["supports_pdf_inputs()"]
  7abe9b90_e935_0a24_a895_1fdedde76d15 -->|method| 6ad9fe16_7cf5_e819_4a9e_84239c16c80c
  7c0c14e4_89d4_dca4_ea33_9e9e2d277895["test_openai_pdf_inputs()"]
  7abe9b90_e935_0a24_a895_1fdedde76d15 -->|method| 7c0c14e4_89d4_dca4_ea33_9e9e2d277895

Relationship Graph

Source Code

libs/partners/openai/tests/integration_tests/chat_models/test_base_standard.py lines 18–123

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

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

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

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

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

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

    @property
    def supported_usage_metadata_details(
        self,
    ) -> dict[
        Literal["invoke", "stream"],
        list[
            Literal[
                "audio_input",
                "audio_output",
                "reasoning_output",
                "cache_read_input",
                "cache_creation_input",
            ]
        ],
    ]:
        return {"invoke": ["reasoning_output", "cache_read_input"], "stream": []}

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

    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-4o-mini", stream_usage=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="gpt-5-nano", reasoning_effort="medium")
        input_ = (
            "explain  the relationship between the 2008/9 economic crisis and the "
            "startup ecosystem in the early 2010s"
        )
        return _invoke(llm, input_, stream)

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

    @pytest.mark.flaky(retries=3, delay=1)
    def test_openai_pdf_inputs(self, model: BaseChatModel) -> None:
        """Test that the model can process PDF inputs."""
        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")

        message = HumanMessage(
            [

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free