New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

azure-langchain-example

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Malware was recently detected in this package.

Affected versions:

0.1.0

azure-langchain-example

A minimal LangChain wrapper for Azure OpenAI

pipPyPI
Version
0.1.0
Weekly downloads
7
-12.5%
Maintainers
1
Weekly downloads
 
Created

Azure LangChain Example

一个用于 Azure OpenAI 与 LangChain 集成的最小 Python 项目示例。

这个项目依赖官方的 langchain-openai 包;它提供 AzureChatOpenAI、 AzureOpenAI 和 AzureOpenAIEmbeddings 等 Azure OpenAI 封装。

安装

pip install azure-langchain-example

若尚未发布到 PyPI,可在项目根目录执行:

pip install -e .

配置

先在 Azure OpenAI 中创建模型部署,然后设置环境变量:

export AZURE_OPENAI_API_KEY="your-api-key"
export AZURE_OPENAI_ENDPOINT="https://your-resource-name.openai.azure.com/"

使用 Azure OpenAI 聊天模型

from langchain_openai import AzureChatOpenAI

llm = AzureChatOpenAI(
    azure_deployment="your-deployment-name",
    api_version="2024-05-01-preview",
    temperature=0,
)

response = llm.invoke("用一句话解释什么是 RAG。")
print(response.content)

azure_deployment 是 Azure 门户中创建的部署名称,可能与底层模型名称不同。

发布

python -m pip install --upgrade build twine
python -m build
python -m twine check dist/*
python -m twine upload --repository testpypi dist/*

确认测试安装无误后,上传正式 PyPI:

python -m twine upload dist/*

每次发布都必须增加 pyproject.toml 中的 version;PyPI 不允许覆盖已上传的版本。

License

MIT

Keywords

azure

FAQs

Related posts