azure.py — langchain Source File
Architecture documentation for azure.py, a python file in the langchain codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR fe99e450_f39e_b29c_2ae7_ae092f3a28f1["azure.py"] cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7["collections.abc"] fe99e450_f39e_b29c_2ae7_ae092f3a28f1 --> cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] fe99e450_f39e_b29c_2ae7_ae092f3a28f1 --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 45fc8fd3_e815_b442_a6d1_0dedc9327b62["openai"] fe99e450_f39e_b29c_2ae7_ae092f3a28f1 --> 45fc8fd3_e815_b442_a6d1_0dedc9327b62 f4d905c6_a2b2_eb8f_be9b_7808b72f6a16["langchain_core.utils"] fe99e450_f39e_b29c_2ae7_ae092f3a28f1 --> f4d905c6_a2b2_eb8f_be9b_7808b72f6a16 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7["pydantic"] fe99e450_f39e_b29c_2ae7_ae092f3a28f1 --> 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7 91721f45_4909_e489_8c1f_084f8bd87145["typing_extensions"] fe99e450_f39e_b29c_2ae7_ae092f3a28f1 --> 91721f45_4909_e489_8c1f_084f8bd87145 384e2971_ebf4_58e9_4d3b_ab3f502084f2["langchain_openai.embeddings.base"] fe99e450_f39e_b29c_2ae7_ae092f3a28f1 --> 384e2971_ebf4_58e9_4d3b_ab3f502084f2 style fe99e450_f39e_b29c_2ae7_ae092f3a28f1 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Azure OpenAI embeddings wrapper."""
from __future__ import annotations
from collections.abc import Awaitable, Callable
from typing import cast
import openai
from langchain_core.utils import from_env, secret_from_env
from pydantic import Field, SecretStr, model_validator
from typing_extensions import Self
from langchain_openai.embeddings.base import OpenAIEmbeddings
class AzureOpenAIEmbeddings(OpenAIEmbeddings): # type: ignore[override]
"""AzureOpenAI embedding model integration.
Setup:
To access AzureOpenAI embedding models you'll need to create an Azure account,
get an API key, and install the `langchain-openai` integration package.
You'll need to have an Azure OpenAI instance deployed.
You can deploy a version on Azure Portal following this
[guide](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/create-resource?pivots=web-portal).
Once you have your instance running, make sure you have the name of your
instance and key. You can find the key in the Azure Portal,
under the “Keys and Endpoint” section of your instance.
```bash
pip install -U langchain_openai
# Set up your environment variables (or pass them directly to the model)
export AZURE_OPENAI_API_KEY="your-api-key"
export AZURE_OPENAI_ENDPOINT="https://<your-endpoint>.openai.azure.com/"
export AZURE_OPENAI_API_VERSION="2024-02-01"
```
Key init args — completion params:
model:
Name of `AzureOpenAI` model to use.
dimensions:
Number of dimensions for the embeddings. Can be specified only if the
underlying model supports it.
See full list of supported init args and their descriptions in the params section.
Instantiate:
```python
from langchain_openai import AzureOpenAIEmbeddings
embeddings = AzureOpenAIEmbeddings(
model="text-embedding-3-large"
# dimensions: int | None = None, # Can specify dimensions with new text-embedding-3 models
# azure_endpoint="https://<your-endpoint>.openai.azure.com/", If not provided, will read env variable AZURE_OPENAI_ENDPOINT
# api_key=... # Can provide an API key directly. If missing read env variable AZURE_OPENAI_API_KEY
# openai_api_version=..., # If not provided, will read env variable AZURE_OPENAI_API_VERSION
)
```
// ... (171 more lines)
Domain
Subdomains
Classes
Dependencies
- collections.abc
- langchain_core.utils
- langchain_openai.embeddings.base
- openai
- pydantic
- typing
- typing_extensions
Source
Frequently Asked Questions
What does azure.py do?
azure.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, Serialization subdomain.
What does azure.py depend on?
azure.py imports 7 module(s): collections.abc, langchain_core.utils, langchain_openai.embeddings.base, openai, pydantic, typing, typing_extensions.
Where is azure.py in the architecture?
azure.py is located at libs/partners/openai/langchain_openai/embeddings/azure.py (domain: CoreAbstractions, subdomain: Serialization, directory: libs/partners/openai/langchain_openai/embeddings).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free