Home / File/ test_azure.py — langchain Source File

test_azure.py — langchain Source File

Architecture documentation for test_azure.py, a python file in the langchain codebase. 8 imports, 0 dependents.

File python CoreAbstractions MessageSchema 8 imports 18 functions

Entity Profile

Dependency Diagram

graph LR
  17e25eb1_2ac4_8c43_237e_360600e9debe["test_azure.py"]
  9e98f0a7_ec6e_708f_4f1b_e9428b316e1c["os"]
  17e25eb1_2ac4_8c43_237e_360600e9debe --> 9e98f0a7_ec6e_708f_4f1b_e9428b316e1c
  cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7["collections.abc"]
  17e25eb1_2ac4_8c43_237e_360600e9debe --> cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7
  8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"]
  17e25eb1_2ac4_8c43_237e_360600e9debe --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3
  120e2591_3e15_b895_72b6_cb26195e40a6["pytest"]
  17e25eb1_2ac4_8c43_237e_360600e9debe --> 120e2591_3e15_b895_72b6_cb26195e40a6
  f3bc7443_c889_119d_0744_aacc3620d8d2["langchain_core.callbacks"]
  17e25eb1_2ac4_8c43_237e_360600e9debe --> f3bc7443_c889_119d_0744_aacc3620d8d2
  ac2a9b92_4484_491e_1b48_ec85e71e1d58["langchain_core.outputs"]
  17e25eb1_2ac4_8c43_237e_360600e9debe --> ac2a9b92_4484_491e_1b48_ec85e71e1d58
  0b28cff6_d823_1571_d2bb_ec61508cc89c["langchain_openai"]
  17e25eb1_2ac4_8c43_237e_360600e9debe --> 0b28cff6_d823_1571_d2bb_ec61508cc89c
  c2b939d8_ea65_23ed_f553_c7331ab00ffa["tests.unit_tests.fake.callbacks"]
  17e25eb1_2ac4_8c43_237e_360600e9debe --> c2b939d8_ea65_23ed_f553_c7331ab00ffa
  style 17e25eb1_2ac4_8c43_237e_360600e9debe fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"""Test AzureOpenAI wrapper."""

import os
from collections.abc import Generator
from typing import Any

import pytest
from langchain_core.callbacks import CallbackManager
from langchain_core.outputs import LLMResult

from langchain_openai import AzureOpenAI
from tests.unit_tests.fake.callbacks import FakeCallbackHandler

OPENAI_API_VERSION = os.environ.get("AZURE_OPENAI_API_VERSION", "")
OPENAI_API_BASE = os.environ.get("AZURE_OPENAI_API_BASE", "")
OPENAI_API_KEY = os.environ.get("AZURE_OPENAI_API_KEY", "")
DEPLOYMENT_NAME = os.environ.get(
    "AZURE_OPENAI_DEPLOYMENT_NAME",
    os.environ.get("AZURE_OPENAI_LLM_DEPLOYMENT_NAME", ""),
)

pytestmark = pytest.mark.skipif(
    True,
    reason=(
        "This entire module is skipped as all Azure OpenAI models supporting text "
        "completions are retired. See: "
        "https://learn.microsoft.com/en-us/azure/ai-foundry/openai/concepts/legacy-models"
    ),
)


def _get_llm(**kwargs: Any) -> AzureOpenAI:
    return AzureOpenAI(  # type: ignore[call-arg, call-arg, call-arg]
        deployment_name=DEPLOYMENT_NAME,
        openai_api_version=OPENAI_API_VERSION,
        azure_endpoint=OPENAI_API_BASE,
        openai_api_key=OPENAI_API_KEY,
        **kwargs,
    )


@pytest.fixture
def llm() -> AzureOpenAI:
    return _get_llm(max_tokens=10)


@pytest.mark.scheduled
def test_openai_call(llm: AzureOpenAI) -> None:
    """Test valid call to openai."""
    output = llm.invoke("Say something nice:")
    assert isinstance(output, str)


@pytest.mark.scheduled
def test_openai_streaming(llm: AzureOpenAI) -> None:
    """Test streaming tokens from AzureOpenAI."""
    generator = llm.stream("I'm Pickle Rick")

    assert isinstance(generator, Generator)

// ... (126 more lines)

Subdomains

Dependencies

  • collections.abc
  • langchain_core.callbacks
  • langchain_core.outputs
  • langchain_openai
  • os
  • pytest
  • tests.unit_tests.fake.callbacks
  • typing

Frequently Asked Questions

What does test_azure.py do?
test_azure.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, MessageSchema subdomain.
What functions are defined in test_azure.py?
test_azure.py defines 18 function(s): _get_llm, llm, test_openai_abatch, test_openai_abatch_tags, test_openai_ainvoke, test_openai_astream, test_openai_async_generate, test_openai_async_streaming_callback, test_openai_batch, test_openai_call, and 8 more.
What does test_azure.py depend on?
test_azure.py imports 8 module(s): collections.abc, langchain_core.callbacks, langchain_core.outputs, langchain_openai, os, pytest, tests.unit_tests.fake.callbacks, typing.
Where is test_azure.py in the architecture?
test_azure.py is located at libs/partners/openai/tests/integration_tests/llms/test_azure.py (domain: CoreAbstractions, subdomain: MessageSchema, directory: libs/partners/openai/tests/integration_tests/llms).

Analyze Your Own Codebase

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

Try Supermodel Free