Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for managed identity for Azure OpenAI #922

Merged
merged 3 commits into from
Jun 11, 2024

Conversation

manekinekko
Copy link
Contributor

This PR adds support for Managed Identity in Azure OpenAI.

Here is what the new LlamaIndex settings look like, when using Managed Identity:

import {
  DefaultAzureCredential,
  getBearerTokenProvider,
} from "@azure/identity";

async function initAzureOpenAI() {
  const credential = new DefaultAzureCredential();
  const azureADTokenProvider = getBearerTokenProvider(
    credential,
    "https://cognitiveservices.azure.com/.default",
  );

  const azure = {
    azureADTokenProvider,
    deployment: process.env.AZURE_OPENAI_DEPLOYMENT ?? "gpt-35-turbo",
  };

  // configure LLM model
  Settings.llm = new OpenAI({
    azure,
  }) as any;

  // configure embedding model
  azure.deployment = process.env.EMBEDDING_MODEL as string;
  Settings.embedModel = new OpenAIEmbedding({
    azure,
    model: process.env.EMBEDDING_MODEL,
    dimensions: process.env.EMBEDDING_DIM
      ? parseInt(process.env.EMBEDDING_DIM)
      : undefined,
  });
}

Related issue #921

Copy link

changeset-bot bot commented Jun 11, 2024

🦋 Changeset detected

Latest commit: c9fde31

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 10 packages
Name Type
llamaindex Patch
docs Patch
@llamaindex/community Patch
@llamaindex/experimental Patch
@llamaindex/cloudflare-worker-agent-test Patch
@llamaindex/next-agent-test Patch
@llamaindex/nextjs-edge-runtime-test Patch
@llamaindex/waku-query-engine-test Patch
@llamaindex/autotool-01-node-example Patch
@llamaindex/autotool-02-next-example Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Jun 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
llama-index-ts-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 11, 2024 8:28pm

manekinekko added a commit to Azure-Samples/llama-index-javascript that referenced this pull request Jun 11, 2024
@manekinekko manekinekko marked this pull request as ready for review June 11, 2024 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants