npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

azure-openai-provider

v0.1.2

Published

Vercel AI Provider for running Large Language Models using Azure OpenAI

Downloads

120

Readme

azure-openai-provider

Vercel AI Provider for running Large Language Models using Azure OpenAI

Note: This module currently supports chat models and text inputs. Completion and embeddings is not currently implemented.

Note: This module is under development and may contain errors and frequent incompatible changes.

All releases will be of type MAJOR following the 0.MAJOR.MINOR scheme. Only bugs and non-breaking updates will be released as MINOR. Please read the Tested models and capabilities section to know about the features implemented in this provider.

Installation

The Azure OpenAI provider is available in the azure-openai-provider module. You can install it with

npm i azure-openai-provider
yarn add azure-openai-provider

Provider Instance

Unlike other providers, there is no default instance and you must create your own instance:

import { createAzureOpenAI } from 'azure-openai-provider';

const azureOpenAI = createAzureOpenAI({
  resourceName: 'YourAzureOpenAIResourceName',
  // or baseURL if using a proxy. baseURL: 'https://apigateway.acme.com'
});

await streamText({
  model: azureOpenAi('modelId', 'yourDeploymentName'),
  ...
})

You can use the following optional settings to customize the Azure OpenAI provider instance:

  • resourceName string

    Required if baseURL is not specified. The provider will format the base url to be https://${resourceName}.azure.openai.com

  • baseURL string

    Use a different URL prefix for API calls, e.g. to use proxy servers. If baseURL is passed it will override the resourceName property. Note: the provider will append /openai/deployments/${this.deploymentName} to the end of the baseURL ex. baseURL: "https://apigateway.acme.com"

  • headers Record<string,string>

    Custom headers to include in the requests.

About

This package is a slightly modified version of the official OpenAI provider by Vercel.

Summary of current changes: Added apiVersion and resourceName to the provider options Mapped apiKey to the api-key header, instead of the 'Authorization' header Change convert-to-openai-chat-message.ts to map user messages as {role: "user", content: string} instead of the new format. This will likely break vision capable models

Models

The first argument is you the openai model id. This is not currently utilized but could be in the future.

The second argument is your azure deployment name, e.g. gpt-4-turbo-deployment.

const model = azureOpenAI('gpt-4-1106-preview', 'gpt-4-turbo-deployment');

Examples

Inside the examples folder, you will find some example projects to see how the provider works. Each folder has its own README with the usage description.

Tested capabilities

AI SDK Core

✅ - confirmed working ❌ - does not work

| Method | Status | | -------------- | -------------------------- | | generateText | ✅ | | streamText | ✅ | | generateObject | ✅ | | streamObject | untested (assumed working) |

AI SDK UI

| Method | Status | | ------------- | ------------------------------ | | useChat | ✅ | | useCompletion | ❌ | | useAssistant | untested (assumed not working) |

AI SDK RSC

| Method | Status | | ------------------ | ------ | | createStreamableUI | ✅ |