test_azure.py — langchain Source File
Architecture documentation for test_azure.py, a python file in the langchain codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR de88be27_979f_5aac_c712_727caa03d6f9["test_azure.py"] 9e98f0a7_ec6e_708f_4f1b_e9428b316e1c["os"] de88be27_979f_5aac_c712_727caa03d6f9 --> 9e98f0a7_ec6e_708f_4f1b_e9428b316e1c 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] de88be27_979f_5aac_c712_727caa03d6f9 --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 cd17727f_b882_7f06_aadc_71fbf75bebb0["numpy"] de88be27_979f_5aac_c712_727caa03d6f9 --> cd17727f_b882_7f06_aadc_71fbf75bebb0 45fc8fd3_e815_b442_a6d1_0dedc9327b62["openai"] de88be27_979f_5aac_c712_727caa03d6f9 --> 45fc8fd3_e815_b442_a6d1_0dedc9327b62 120e2591_3e15_b895_72b6_cb26195e40a6["pytest"] de88be27_979f_5aac_c712_727caa03d6f9 --> 120e2591_3e15_b895_72b6_cb26195e40a6 0b28cff6_d823_1571_d2bb_ec61508cc89c["langchain_openai"] de88be27_979f_5aac_c712_727caa03d6f9 --> 0b28cff6_d823_1571_d2bb_ec61508cc89c style de88be27_979f_5aac_c712_727caa03d6f9 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Test azure openai embeddings."""
import os
from typing import Any
import numpy as np
import openai
import pytest
from langchain_openai import AzureOpenAIEmbeddings
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_EMBEDDINGS_DEPLOYMENT_NAME", ""),
)
print
def _get_embeddings(**kwargs: Any) -> AzureOpenAIEmbeddings:
return AzureOpenAIEmbeddings( # type: ignore[call-arg]
azure_deployment=DEPLOYMENT_NAME,
api_version=OPENAI_API_VERSION,
azure_endpoint=OPENAI_API_BASE,
openai_api_key=OPENAI_API_KEY,
**kwargs,
)
@pytest.mark.scheduled
def test_azure_openai_embedding_documents() -> None:
"""Test openai embeddings."""
documents = ["foo bar"]
embedding = _get_embeddings()
output = embedding.embed_documents(documents)
assert len(output) == 1
assert len(output[0]) == 1536
@pytest.mark.scheduled
def test_azure_openai_embedding_documents_multiple() -> None:
"""Test openai embeddings."""
documents = ["foo bar", "bar foo", "foo"]
embedding = _get_embeddings(chunk_size=2)
embedding.embedding_ctx_length = 8191
output = embedding.embed_documents(documents)
assert embedding.chunk_size == 2
assert len(output) == 3
assert len(output[0]) == 1536
assert len(output[1]) == 1536
assert len(output[2]) == 1536
@pytest.mark.scheduled
def test_azure_openai_embedding_documents_chunk_size() -> None:
"""Test openai embeddings."""
documents = ["foo bar"] * 20
embedding = _get_embeddings()
// ... (74 more lines)
Domain
Subdomains
Functions
- _get_embeddings()
- test_azure_openai_embedding_async_query()
- test_azure_openai_embedding_documents()
- test_azure_openai_embedding_documents_async_multiple()
- test_azure_openai_embedding_documents_chunk_size()
- test_azure_openai_embedding_documents_multiple()
- test_azure_openai_embedding_query()
- test_azure_openai_embedding_with_empty_string()
- test_embed_documents_normalized()
- test_embed_query_normalized()
Dependencies
- langchain_openai
- numpy
- openai
- os
- pytest
- 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, Serialization subdomain.
What functions are defined in test_azure.py?
test_azure.py defines 10 function(s): _get_embeddings, test_azure_openai_embedding_async_query, test_azure_openai_embedding_documents, test_azure_openai_embedding_documents_async_multiple, test_azure_openai_embedding_documents_chunk_size, test_azure_openai_embedding_documents_multiple, test_azure_openai_embedding_query, test_azure_openai_embedding_with_empty_string, test_embed_documents_normalized, test_embed_query_normalized.
What does test_azure.py depend on?
test_azure.py imports 6 module(s): langchain_openai, numpy, openai, os, pytest, typing.
Where is test_azure.py in the architecture?
test_azure.py is located at libs/partners/openai/tests/integration_tests/embeddings/test_azure.py (domain: CoreAbstractions, subdomain: Serialization, directory: libs/partners/openai/tests/integration_tests/embeddings).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free