Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Cody: Update Azure OpenAI provider to use azure go client and support additional auth methods #58289

Merged
chwarwick merged 16 commits into
mainfrom
cw/azure-oai-auth
Nov 20, 2023
Merged

Cody: Update Azure OpenAI provider to use azure go client and support additional auth methods #58289
chwarwick merged 16 commits into
mainfrom
cw/azure-oai-auth

Conversation

@chwarwick

@chwarwick chwarwick commented Nov 13, 2023

Copy link
Copy Markdown
Contributor

Converts the Azure OpenAI provider to use Azure's go client for the purpose of supporting additional auth methods beyond the API Key. When the Access token is not specified AzureDefaultCredentials are used which are tried in the following order:

  1. EnvironmentCredential
  2. WorkloadIdentityCredential
  3. ManagedIdentityCredential
  4. AzureCLICredential - useful for local development authenticate via az login

resolves https://github.com/sourcegraph/sourcegraph/issues/58301

Test plan

Update tests
Tested chat & autocomplete with both API Key and default credentials
Verified auth errors after az logout
Embedded multiple repos
Checked embeddings search results used with chat request

@cla-bot cla-bot Bot added the cla-signed label Nov 13, 2023
Comment thread internal/completions/client/client.go Outdated
@chwarwick chwarwick marked this pull request as ready for review November 18, 2023 21:24
@chwarwick chwarwick requested a review from a team November 18, 2023 21:24
@chwarwick chwarwick added backport 5.2 backport/improvement Final touching of existing features labels Nov 20, 2023
@chwarwick chwarwick requested a review from emidoots November 20, 2023 15:33

@emidoots emidoots left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@chwarwick chwarwick merged commit b4ed3cc into main Nov 20, 2023
@chwarwick chwarwick deleted the cw/azure-oai-auth branch November 20, 2023 22:25
@sourcegraph-release-bot

Copy link
Copy Markdown
Collaborator

The backport to 5.2 failed at https://github.com/sourcegraph/sourcegraph/actions/runs/6936532806:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-5.2 5.2
# Navigate to the new working tree
cd .worktrees/backport-5.2
# Create a new branch
git switch --create backport-58289-to-5.2
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 b4ed3cc50a1a548f3c8bbe30fd65782f685a2605
# Push it to GitHub
git push --set-upstream origin backport-58289-to-5.2
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-5.2

If you encouter conflict, first resolve the conflict and stage all files, then run the commands below:

git cherry-pick --continue
# Push it to GitHub
git push --set-upstream origin backport-58289-to-5.2
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-5.2
  • Follow above instructions to backport the commit.
  • Create a pull request where the base branch is 5.2 and the compare/head branch is backport-58289-to-5.2., click here to create the pull request.
  • Make sure to tag @sourcegraph/release-guild in the pull request description.
  • Once the backport pull request is created, kindly remove the release-blocker from this pull request.

@sourcegraph-release-bot sourcegraph-release-bot added the release-blocker Prevents us from releasing: https://about.sourcegraph.com/handbook/engineering/releases label Nov 20, 2023
chwarwick pushed a commit that referenced this pull request Nov 21, 2023
… additional auth methods (#58289)

(cherry picked from commit b4ed3cc)
chwarwick pushed a commit that referenced this pull request Nov 28, 2023
… additional auth methods (#58289)

(cherry picked from commit b4ed3cc)
unknwon pushed a commit that referenced this pull request Nov 28, 2023
vovakulikov pushed a commit that referenced this pull request Dec 12, 2023
@varungandhi-src varungandhi-src mentioned this pull request Jan 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

backport/improvement Final touching of existing features backport 5.2 backports cla-signed failed-backport-to-5.2 release-blocker Prevents us from releasing: https://about.sourcegraph.com/handbook/engineering/releases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cody: Azure OpenAI provider support additional auth methods

3 participants