Skip to main content
Open on GitHub

Azure AI

所有与 Azure AI Foundry 及其相关项目相关的功能。

Azure AI、Dynamic Sessions 和 SQL Server 的集成包维护在 langchain-azure 仓库中。

Chat models

我们建议开发人员从 (langchain-azure-ai) 开始,以访问 Azure AI Foundry 中提供的所有模型。

Azure AI Chat Completions Model

使用 AzureAIChatCompletionsModel 类可以访问 Azure OpenAI、DeepSeek R1、Cohere、Phi 和 Mistral 等模型。

pip install -U langchain-azure-ai

配置您的 API 密钥和终结点。

export AZURE_INFERENCE_CREDENTIAL=your-api-key
export AZURE_INFERENCE_ENDPOINT=your-endpoint
from langchain_azure_ai.chat_models import AzureAIChatCompletionsModel

llm = AzureAIChatCompletionsModel(
model_name="gpt-4o",
api_version="2024-05-01-preview",
)

llm.invoke('Tell me a joke and include some emojis')

Embedding models

Azure AI model inference for embeddings

pip install -U langchain-azure-ai

配置您的 API 密钥和终结点。

export AZURE_INFERENCE_CREDENTIAL=your-api-key
export AZURE_INFERENCE_ENDPOINT=your-endpoint
from langchain_azure_ai.embeddings import AzureAIEmbeddingsModel

embed_model = AzureAIEmbeddingsModel(
model_name="text-embedding-ada-002"
)