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

fix: Support Azure OpenAI #14722

Merged
merged 1 commit into from
Jan 15, 2025
Merged

fix: Support Azure OpenAI #14722

merged 1 commit into from
Jan 15, 2025

Conversation

fipro78
Copy link
Contributor

@fipro78 fipro78 commented Jan 13, 2025

  • Add configuration of OpenAI API version
  • Add configuration of supportsDeveloperMessage
  • If OpenAI API version is configured, use AzureOpenAI

Fixes #14711

What it does

It fixes #14711 and adds support for accessing an OpenAI model deployed on Azure.
To make this work, the AzureOpenAI class needs to be used, as described in the openai-node docs.

To build up the request with AzureOpenAI you need to pass a apiVersion. This PR therefore adds the option to configure the apiVersion in the settings. If no apiVersion is configured, the default OpenAI object is used for initialization.

I also noticed that it can happen, that the OpenAI model version deployed on Azure might not yet support the developer role. Therefore I also added the option to configure whether the developer role is supported or not, which defaults to true.

How to test

The reviewer would need to have an OpenAI model available in Azure and then configure a custom openai model like this:

{
  "ai-features.AiEnable.enableAI": true,
  "ai-features.openAiCustom.customOpenAiModels": [
    {
      "model": "gpt4o",
      "url": "<AZURE_OPENAI_API_BASE_URL>",
      "id": "azure-deployment",
      "apiKey": "<AZURE_OPENAI_API_KEY>",
      "apiVersion": "<AZURE_OPENAI_API_VERSION>",
      "supportsDeveloperMessage": false
    }
  ],
  "ai-features.agentSettings": {
    "Universal": {
      "languageModelRequirements": [
        {
          "purpose": "chat",
          "identifier": "azure-deployment"
        }
      ]
    },
    "Orchestrator": {
      "languageModelRequirements": [
        {
          "purpose": "agent-selection",
          "identifier": "azure-deployment"
        }
      ]
    }
  }
}

Of course a non Azure model deployment should still work as before.

Follow-ups

Breaking changes

  • This PR introduces breaking changes and requires careful review. If yes, the breaking changes section in the changelog has been updated.

Attribution

Review checklist

Reminder for reviewers

Copy link
Contributor

@planger planger left a comment

Choose a reason for hiding this comment

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

Thank you very much @fipro78!

Code looks good to me and existing behavior still seems to work fine. I can't test with Azure though, as I don't have an account at hand at the moment.

Can you please also add a short hint on how to configure/use this to the README.md of this package (like you did in the description of this PR)?

@fipro78
Copy link
Contributor Author

fipro78 commented Jan 14, 2025

@planger
Thanks for the review. I updated the readme.

@JonasHelming JonasHelming removed the request for review from sdirix January 14, 2025 13:12
@JonasHelming
Copy link
Contributor

@planger I guess we can merge this then?

* Add configuration of OpenAI API version
* Add configuration of supportsDeveloperMessage
* If OpenAI API version is configured, use AzureOpenAI

Fixes eclipse-theia#14711
Copy link
Member

@sdirix sdirix left a comment

Choose a reason for hiding this comment

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

Code looks good to me! I don't have an Azure key, so I did not test the new functionality however I did verify that the regular Open AI models continue working.

@JonasHelming JonasHelming merged commit 52d9949 into eclipse-theia:master Jan 15, 2025
11 checks passed
@github-actions github-actions bot added this to the 1.58.0 milestone Jan 15, 2025
@planger planger mentioned this pull request Feb 13, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[Theia AI] Support Azure OpenAI
4 participants