Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
azure-openai
Advanced tools
This is a fork of the official OpenAI Node.js library that has been adapted to support the Azure OpenAI API. The objective of this library is to minimize the changes required to migrate from the official OpenAI library to Azure OpenAI or revert back to OpenAI.
This library allows you to use Azure OpenAI's API without making any changes to your existing OpenAI code. You can simply add Azure information to your configuration and start using the Azure OpenAI model.
To install this library, use the following command:
$ npm install azure-openai
The library needs to be configured with your Azure OpenAI's key, endpoint and deploymentId. you can obtain these credentials from Azure Portal. Please see the below screenshot:
To migrate from the official OpenAI model to the Azure OpenAI model, you can just simply add azure info into configuration to migrate, that is it. You donot need to change any code. Please see the below steps:
Install the library by running the following command:
npm install azure-openai
Update the import statement from "openai" to "azure-openai":
//import { Configuration, OpenAIApi } from "openai";
import { Configuration, OpenAIApi } from "azure-openai";
Add the Azure OpenAI information to your project configuration:
this.openAiApi = new OpenAIApi(
new Configuration({
apiKey: this.apiKey,
// add azure info into configuration
azure: {
apiKey: {your-azure-openai-resource-key},
endpoint: {your-azure-openai-resource-endpoint},
// deploymentName is optional, if you donot set it, you need to set it in the request parameter
deploymentName: {your-azure-openai-resource-deployment-name},
}
}),
);
run your code. That's it.
optional, if you use stream = true. you may need to change response
// Azure OpenAI donot response delta data, so you need to change the response to text
// const delta = parsed.choices[0].delta.content;
const delta = parsed.choices[0].text;
optional, you can also set your Azure deploymentName by replacing your model with deployment name, like this:
const response = await this.openAiApi.createCompletion({
model: {your-azure-openai-resource-deployment-name},
prompt: prompt,
maxTokens: 100,
temperature: 0.9,
topP: 1,
presencePenalty: 0,
frequencyPenalty: 0,
bestOf: 1,
});
support latest version of OpenAI API, v3.2.0.
API | Test Status |
---|---|
createChatCompletion | Pass |
createCompletion | Pass |
createEmbedding | Pass |
createImage | Not Support |
Check Azure OpenAI Rest Spec
Please feel free to submit your issues or pull requests to support other APIs.
FAQs
Node.js library for the Azure OpenAI API
The npm package azure-openai receives a total of 3,112 weekly downloads. As such, azure-openai popularity was classified as popular.
We found that azure-openai demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.