Gathering detailed insights and metrics for @langchain/azure-openai
Gathering detailed insights and metrics for @langchain/azure-openai
Gathering detailed insights and metrics for @langchain/azure-openai
Gathering detailed insights and metrics for @langchain/azure-openai
@trubrics/trubrics
A Trubrics SDK for JavaScript applications
@aurogpt/flowgpt
FlowGPT is an enterprise-grade framework for developing conversational AI bots with structured dialogue flows. Built on LangChain, it provides seamless integration with OpenAI and Azure OpenAI models, enabling developers to create sophisticated conversati
🦜🔗 Build context-aware reasoning applications 🦜🔗
npm install @langchain/azure-openai
Typescript
Module System
Min. Node Version
Node Version
NPM Version
80.1
Supply Chain
97.2
Quality
87.5
Maintenance
100
Vulnerability
100
License
TypeScript (86.44%)
Jupyter Notebook (6.1%)
HTML (4.29%)
JavaScript (2.76%)
Shell (0.19%)
MDX (0.14%)
CSS (0.09%)
Python (0.01%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
433,318
Last Day
763
Last Week
7,957
Last Month
33,208
Last Year
432,353
MIT License
13,557 Stars
5,302 Commits
2,332 Forks
81 Watchers
24 Branches
845 Contributors
Updated on Feb 17, 2025
Minified
Minified + Gzipped
Latest Version
0.0.11
Package Id
@langchain/azure-openai@0.0.11
Unpacked Size
124.14 kB
Size
20.73 kB
File Count
28
NPM Version
10.7.0
Node Version
22.2.0
Published on
Jun 12, 2024
Cumulative downloads
Total Downloads
Last Day
1.3%
763
Compared to previous day
Last Week
-8.7%
7,957
Compared to previous week
Last Month
15.8%
33,208
Compared to previous month
Last Year
44,703.4%
432,353
Compared to previous year
20
[!IMPORTANT] This package is now deprecated in favor of the new Azure integration in the OpenAI SDK. Please use the package
@langchain/openai
instead. You can find the migration guide here.
This package contains the Azure SDK for OpenAI LangChain.js integrations.
It provides Azure OpenAI support through the Azure SDK for OpenAI library.
1npm install @langchain/azure-openai
This package, along with the main LangChain package, depends on @langchain/core
.
If you are using this package with other LangChain packages, you should make sure that all of the packages depend on the same instance of @langchain/core.
You can do so by adding appropriate fields to your project's package.json
like this:
1{ 2 "name": "your-project", 3 "version": "0.0.0", 4 "dependencies": { 5 "@langchain/azure-openai": "^0.0.4", 6 "langchain": "0.0.207" 7 }, 8 "resolutions": { 9 "@langchain/core": "0.1.5" 10 }, 11 "overrides": { 12 "@langchain/core": "0.1.5" 13 }, 14 "pnpm": { 15 "overrides": { 16 "@langchain/core": "0.1.5" 17 } 18 } 19}
The field you need depends on the package manager you're using, but we recommend adding a field for the common yarn
, npm
, and pnpm
to maximize compatibility.
This package contains the AzureChatOpenAI
class, which is the recommended way to interface with deployed models on Azure OpenAI.
To use, install the requirements, and configure your environment.
1export AZURE_OPENAI_API_ENDPOINT=<your_endpoint> 2export AZURE_OPENAI_API_KEY=<your_key> 3export AZURE_OPENAI_API_DEPLOYMENT_NAME=<your_deployment_name>
Then initialize the model and make the calls:
1import { AzureChatOpenAI } from "@langchain/azure-openai"; 2 3const model = new AzureChatOpenAI({ 4 // Note that the following are optional, and will default to the values below 5 // if not provided. 6 azureOpenAIEndpoint: process.env.AZURE_OPENAI_API_ENDPOINT, 7 azureOpenAIApiKey: process.env.AZURE_OPENAI_API_KEY, 8 azureOpenAIApiDeploymentName: process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME, 9}); 10const response = await model.invoke(new HumanMessage("Hello world!"));
1import { AzureChatOpenAI } from "@langchain/azure-openai"; 2 3const model = new AzureChatOpenAI({ 4 // Note that the following are optional, and will default to the values below 5 // if not provided. 6 azureOpenAIEndpoint: process.env.AZURE_OPENAI_API_ENDPOINT, 7 azureOpenAIApiKey: process.env.AZURE_OPENAI_API_KEY, 8 azureOpenAIApiDeploymentName: process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME, 9}); 10const response = await model.stream(new HumanMessage("Hello world!"));
This package also supports embeddings with Azure OpenAI.
1import { AzureOpenAIEmbeddings } from "@langchain/azure-openai"; 2 3const embeddings = new AzureOpenAIEmbeddings({ 4 // Note that the following are optional, and will default to the values below 5 // if not provided. 6 azureOpenAIEndpoint: process.env.AZURE_OPENAI_API_ENDPOINT, 7 azureOpenAIApiKey: process.env.AZURE_OPENAI_API_KEY, 8 azureOpenAIApiDeploymentName: process.env.AZURE_OPENAI_API_EMBEDDINGS_DEPLOYMENT_NAME, 9}); 10const res = await embeddings.embedQuery("Hello world");
If you're using Azure Managed Identity, you can also pass the credentials directly to the constructor:
1import { DefaultAzureCredential } from "@azure/identity"; 2import { AzureOpenAI } from "@langchain/azure-openai"; 3 4const credentials = new DefaultAzureCredential(); 5 6const model = new AzureOpenAI({ 7 credentials, 8 azureOpenAIEndpoint: process.env.AZURE_OPENAI_API_ENDPOINT, 9 azureOpenAIApiDeploymentName: process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME, 10});
This library is provides compatibility with the OpenAI API. You can use an API key from OpenAI's developer portal like in the example below:
1import { AzureOpenAI, OpenAIKeyCredential } from "@langchain/azure-openai"; 2 3const model = new AzureOpenAI({ 4 modelName: "gpt-3.5-turbo", 5 credentials: new OpenAIKeyCredential("<your_openai_api_key>"), 6});
To develop the Azure OpenAI package, you'll need to follow these instructions:
1yarn install
1yarn build
Or from the repo root:
1yarn build --filter=@langchain/azure-openai
Test files should live within a tests/
file in the src/
folder. Unit tests should end in .test.ts
and integration tests should
end in .int.test.ts
:
1$ yarn test 2$ yarn test:int
Run the linter & formatter to ensure your code is up to standard:
1yarn lint && yarn format
If you add a new file to be exported, either import & re-export from src/index.ts
, or add it to scripts/create-entrypoints.js
and run yarn build
to generate the new entrypoint.
No vulnerabilities found.
No security vulnerabilities found.