test_azure.py — langchain Source File
Architecture documentation for test_azure.py, a python file in the langchain codebase. 10 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 06d8c8fd_0118_258b_5e39_fe4b6740f0c5["test_azure.py"] 7025b240_fdc3_cf68_b72f_f41dac94566b["json"] 06d8c8fd_0118_258b_5e39_fe4b6740f0c5 --> 7025b240_fdc3_cf68_b72f_f41dac94566b 9e98f0a7_ec6e_708f_4f1b_e9428b316e1c["os"] 06d8c8fd_0118_258b_5e39_fe4b6740f0c5 --> 9e98f0a7_ec6e_708f_4f1b_e9428b316e1c 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] 06d8c8fd_0118_258b_5e39_fe4b6740f0c5 --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 120e2591_3e15_b895_72b6_cb26195e40a6["pytest"] 06d8c8fd_0118_258b_5e39_fe4b6740f0c5 --> 120e2591_3e15_b895_72b6_cb26195e40a6 f3bc7443_c889_119d_0744_aacc3620d8d2["langchain_core.callbacks"] 06d8c8fd_0118_258b_5e39_fe4b6740f0c5 --> f3bc7443_c889_119d_0744_aacc3620d8d2 d758344f_537f_649e_f467_b9d7442e86df["langchain_core.messages"] 06d8c8fd_0118_258b_5e39_fe4b6740f0c5 --> d758344f_537f_649e_f467_b9d7442e86df ac2a9b92_4484_491e_1b48_ec85e71e1d58["langchain_core.outputs"] 06d8c8fd_0118_258b_5e39_fe4b6740f0c5 --> ac2a9b92_4484_491e_1b48_ec85e71e1d58 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7["pydantic"] 06d8c8fd_0118_258b_5e39_fe4b6740f0c5 --> 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7 0b28cff6_d823_1571_d2bb_ec61508cc89c["langchain_openai"] 06d8c8fd_0118_258b_5e39_fe4b6740f0c5 --> 0b28cff6_d823_1571_d2bb_ec61508cc89c c2b939d8_ea65_23ed_f553_c7331ab00ffa["tests.unit_tests.fake.callbacks"] 06d8c8fd_0118_258b_5e39_fe4b6740f0c5 --> c2b939d8_ea65_23ed_f553_c7331ab00ffa style 06d8c8fd_0118_258b_5e39_fe4b6740f0c5 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Test AzureChatOpenAI wrapper."""
from __future__ import annotations
import json
import os
from typing import Any
import pytest
from langchain_core.callbacks import CallbackManager
from langchain_core.messages import (
AIMessageChunk,
BaseMessage,
BaseMessageChunk,
HumanMessage,
)
from langchain_core.outputs import ChatGeneration, ChatResult, LLMResult
from pydantic import BaseModel
from langchain_openai import AzureChatOpenAI
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_CHAT_DEPLOYMENT_NAME", ""),
)
def _get_llm(**kwargs: Any) -> AzureChatOpenAI:
return AzureChatOpenAI( # 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.mark.scheduled
@pytest.fixture
def llm() -> AzureChatOpenAI:
return _get_llm(max_tokens=50)
def test_chat_openai(llm: AzureChatOpenAI) -> None:
"""Test AzureChatOpenAI wrapper."""
message = HumanMessage(content="Hello")
response = llm.invoke([message])
assert isinstance(response, BaseMessage)
assert isinstance(response.content, str)
@pytest.mark.scheduled
def test_chat_openai_generate() -> None:
"""Test AzureChatOpenAI wrapper with generate."""
chat = _get_llm(max_tokens=10, n=2)
message = HumanMessage(content="Hello")
// ... (242 more lines)
Domain
Subdomains
Functions
- _get_llm()
- llm()
- test_astream_response_format()
- test_async_chat_openai()
- test_async_chat_openai_streaming()
- test_chat_openai()
- test_chat_openai_generate()
- test_chat_openai_multiple_completions()
- test_chat_openai_streaming()
- test_chat_openai_streaming_generation_info()
- test_json_mode()
- test_json_mode_async()
- test_openai_abatch()
- test_openai_abatch_tags()
- test_openai_ainvoke()
- test_openai_astream()
- test_openai_batch()
- test_openai_invoke()
- test_openai_streaming()
- test_stream_response_format()
Classes
Dependencies
- json
- langchain_core.callbacks
- langchain_core.messages
- langchain_core.outputs
- langchain_openai
- os
- pydantic
- pytest
- tests.unit_tests.fake.callbacks
- typing
Source
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 20 function(s): _get_llm, llm, test_astream_response_format, test_async_chat_openai, test_async_chat_openai_streaming, test_chat_openai, test_chat_openai_generate, test_chat_openai_multiple_completions, test_chat_openai_streaming, test_chat_openai_streaming_generation_info, and 10 more.
What does test_azure.py depend on?
test_azure.py imports 10 module(s): json, langchain_core.callbacks, langchain_core.messages, langchain_core.outputs, langchain_openai, os, pydantic, pytest, and 2 more.
Where is test_azure.py in the architecture?
test_azure.py is located at libs/partners/openai/tests/integration_tests/chat_models/test_azure.py (domain: CoreAbstractions, subdomain: MessageSchema, directory: libs/partners/openai/tests/integration_tests/chat_models).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free