Skip to content

Use openai package instead of legacy azure openai package (#12375)#12376

Open
yasmoradi wants to merge 5 commits into
bitfoundation:developfrom
yasmoradi:12375
Open

Use openai package instead of legacy azure openai package (#12375)#12376
yasmoradi wants to merge 5 commits into
bitfoundation:developfrom
yasmoradi:12375

Conversation

@yasmoradi
Copy link
Copy Markdown
Member

@yasmoradi yasmoradi commented May 25, 2026

closes #12375

Summary by CodeRabbit

  • Improvements

    • Removed Azure OpenAI support; application now uses OpenAI exclusively for AI features.
    • Adjusted default chat temperature from 0 to 1 for more varied responses.
    • Simplified configuration setup process.
  • Documentation

    • Updated configuration guides and examples for OpenAI API key setup.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 25, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 6458ba3c-c082-4bff-aed0-754c06b85dff

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

This PR removes the legacy Microsoft.Extensions.AI.AzureAIInference package and Azure OpenAI configuration from the codebase, consolidating chat client setup to OpenAI only. Configuration classes, package references, service registration branches, and settings files are updated across BlazorUI Demo, ResxTranslator, Boilerplate template, and Platform website projects.

Changes

Azure OpenAI Removal Across Codebase

Layer / File(s) Summary
BlazorUI Demo: remove Azure OpenAI
src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/AppSettings.cs, Bit.BlazorUI.Demo.Server.csproj, Startup/Services.cs, appsettings.json
Remove AzureOpenAI property and AzureOpenAIOptions class from AppSettings, remove package dependency, change OpenAI registration from else if to if, and update chat temperature to 1.
ResxTranslator: settings and runtime consolidation
src/ResxTranslator/Bit.ResxTranslator/Bit.ResxTranslator.csproj, Models/ResxTranslatorSettings.cs, Program.cs
Rename AzureOpenAI to OpenAI in settings, remove Azure Inference package, and remove Azure OpenAI conditional branch from chat client registration.
ResxTranslator: documentation and template updates
README.md, src/Templates/Boilerplate/Bit.Boilerplate/Bit.ResxTranslator.json
Update README to recommend OpenAI__ApiKey environment variable and provide endpoint samples for multiple providers; extend template JSON with endpoint and API key documentation.
Boilerplate: central package and project file updates
src/Templates/Boilerplate/Bit.Boilerplate/src/Directory.Packages.props, Server/Boilerplate.Server.Api/Boilerplate.Server.Api.csproj
Remove Azure Inference from central package management and replace with OpenAI package in API project.
Boilerplate: service registration logic
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Program.Services.cs
Remove Azure OpenAI conditional branches from chat and embedding registration; proceed directly to HuggingFace options after OpenAI setup.
Boilerplate: configuration models
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/ServerApiSettings.cs
Remove AzureOpenAI property and AzureOpenAIOptions class from AI configuration.
Boilerplate: configuration settings
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/appsettings.json, Boilerplate.Server.Web/appsettings.json
Add endpoint sample documentation to API OpenAI ChatOptions and remove AzureOpenAI block from Web settings.
Platform website: remove Azure OpenAI
src/Websites/Platform/src/Bit.Websites.Platform.Server/Bit.Websites.Platform.Server.csproj, Startup/Services.cs, appsettings.json
Remove package dependency, change chat client registration to standalone if, and update temperature to 1.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Azure paths are closed today,
OpenAI shows the way.
Templates sing with settings clear,
Simpler configs, no more fear!
One true path through every layer,
Hop along with your tech repair. 🌟

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR includes unrelated configuration changes: temperature settings were modified from 0 to 1 in appsettings.json files, which are outside the scope of replacing the Azure OpenAI package. Remove temperature configuration changes from appsettings.json in Demo and Platform server projects, as they are unrelated to the package migration objective.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately and concisely describes the main objective: replacing the legacy Azure OpenAI package with the OpenAI package, which is reflected throughout all code changes.
Linked Issues check ✅ Passed The PR successfully replaces the legacy Azure OpenAI package (Microsoft.Extensions.AI.AzureAIInference) with the OpenAI package across all projects and configuration files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the Platform server, BlazorUI Demo server, Boilerplate templates, and the ResxTranslator tool away from the legacy Microsoft.Extensions.AI.AzureAIInference (Azure Azure.AI.Inference.* clients) to the Microsoft.Extensions.AI.OpenAI integration, removing the AzureAIInference package references and associated AzureOpenAI configuration paths.

Changes:

  • Removed Microsoft.Extensions.AI.AzureAIInference package references and deleted AzureOpenAI chat/embedding wiring in service registration.
  • Simplified configuration models and appsettings templates by removing AzureOpenAI sections (mostly) and expanding OpenAI endpoint samples.
  • Updated ResxTranslator docs/config guidance to focus on OpenAI configuration (but requires fixes; see comments).

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/Websites/Platform/src/Bit.Websites.Platform.Server/Startup/Services.cs Removes AzureOpenAI chat client wiring; registers OpenAI chat client only.
src/Websites/Platform/src/Bit.Websites.Platform.Server/Bit.Websites.Platform.Server.csproj Drops AzureAIInference package reference.
src/Websites/Platform/src/Bit.Websites.Platform.Server/appsettings.json Changes default chat temperature; AzureOpenAI section still present.
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Web/appsettings.json Removes AzureOpenAI block from template config.
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/ServerApiSettings.cs Removes AzureOpenAIOptions from settings model.
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Program.Services.cs Removes AzureOpenAI chat + embedding registration paths.
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Boilerplate.Server.Api.csproj Drops AzureAIInference package reference (conditional).
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/appsettings.json Removes AzureOpenAI config and adds OpenAI endpoint sample keys.
src/Templates/Boilerplate/Bit.Boilerplate/src/Directory.Packages.props Removes centrally-managed AzureAIInference package version.
src/Templates/Boilerplate/Bit.Boilerplate/Bit.ResxTranslator.json Removes AzureOpenAI provider config; adds OpenAI endpoint samples and key comment.
src/ResxTranslator/README.md Updates env var guidance; adds endpoint samples (needs corrections).
src/ResxTranslator/Bit.ResxTranslator/Program.cs Removes AzureOpenAI branch (but leaves Azure-related wording/usings; needs fixes).
src/ResxTranslator/Bit.ResxTranslator/Models/ResxTranslatorSettings.cs Removes AzureOpenAI settings property.
src/ResxTranslator/Bit.ResxTranslator/Bit.ResxTranslator.csproj Drops AzureAIInference package reference.
src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Startup/Services.cs Removes AzureOpenAI chat client wiring; registers OpenAI chat client only.
src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Bit.BlazorUI.Demo.Server.csproj Drops AzureAIInference package reference.
src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/appsettings.json Removes AzureOpenAI config and changes default chat temperature.
src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/AppSettings.cs Removes AzureOpenAI options model from demo server settings.
Comments suppressed due to low confidence (2)

src/ResxTranslator/Bit.ResxTranslator/Program.cs:68

  • The Azure OpenAI branch was removed, but the fallback exception message still says "No OpenAI or Azure OpenAI API key provided." and the file still imports Azure-specific namespaces (Azure.AI.Inference / Azure.Core.Pipeline). With Microsoft.Extensions.AI.AzureAIInference removed from the project, these Azure usings will likely fail compilation and the message is now misleading. Update the error text to only mention OpenAI, and remove any remaining Azure-specific usings/references in this file.
else
{
    throw new InvalidOperationException("No OpenAI or Azure OpenAI API key provided.");
}

src/Websites/Platform/src/Bit.Websites.Platform.Server/Startup/Services.cs:55

  • AzureOpenAI-based chat client registration was removed, but this project still has AzureOpenAI settings in AppSettings/appsettings.json. As a result, deployments that only set AppSettings:AzureOpenAI:ChatApiKey (and not OpenAI:ChatApiKey) will no longer register an IChatClient and the chatbot features will silently stop working. Either remove AzureOpenAI from the configuration surface, or keep backward compatibility by mapping AzureOpenAI settings to the OpenAI client configuration.
        if (string.IsNullOrEmpty(appSettings?.OpenAI?.ChatApiKey) is false)
        {
            // https://github.com/dotnet/extensions/tree/main/src/Libraries/Microsoft.Extensions.AI.OpenAI#microsoftextensionsaiopenai
            services.AddChatClient(sp => new OpenAI.Chat.ChatClient(model: appSettings.OpenAI.ChatModel, credential: new(appSettings.OpenAI.ChatApiKey), options: new()
            {
                Endpoint = appSettings.OpenAI.ChatEndpoint,
                Transport = new HttpClientPipelineTransport(sp.GetRequiredService<IHttpClientFactory>().CreateClient("AI"))
            }).AsIChatClient())
            .UseLogging()
            .UseFunctionInvocation()
            .UseDistributedCache();
        }

Comment thread src/ResxTranslator/README.md
Comment thread src/ResxTranslator/README.md
Comment thread src/ResxTranslator/README.md Outdated
Comment thread src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/appsettings.json
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/ResxTranslator/README.md (1)

3-3: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Remove stale Azure OpenAI references from README text.

These lines still state OpenAI or Azure OpenAI, which conflicts with the OpenAI-only runtime/config changes in this PR stack and can mislead setup decisions.

Also applies to: 9-9, 26-26

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/ResxTranslator/README.md` at line 3, The README's description for
Bit.ResxTranslator still mentions "OpenAI or Azure OpenAI" which is stale;
update all occurrences (e.g., the initial sentence containing "OpenAI or Azure
OpenAI" and the other lines flagged) to reference only "OpenAI" (remove "or
Azure OpenAI" and any Azure-specific phrasing), and scan the README for any
other Azure OpenAI mentions (lines similar to the phrase) and replace them with
OpenAI-only wording to reflect the runtime/config changes.
🧹 Nitpick comments (1)
src/Websites/Platform/src/Bit.Websites.Platform.Server/appsettings.json (1)

18-29: ⚡ Quick win

Remove stale AzureOpenAI configuration from Platform settings.

The runtime registration path is OpenAI-only, so keeping AppSettings.AzureOpenAI here is obsolete and can cause operator confusion about which key/endpoint is active.

Proposed cleanup
         "ChatOptions": {
             "Temperature": 1
         },
-        "AzureOpenAI": {
-            "ChatModel": "gpt-4.1-mini",
-            "ChatApiKey": null,
-            "ChatEndpoint": null
-        },
         "OpenAI": {
             "ChatModel": "gpt-4.1-mini",
             "ChatApiKey": null,
             "ChatEndpoint": null
         }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Websites/Platform/src/Bit.Websites.Platform.Server/appsettings.json`
around lines 18 - 29, Remove the obsolete AzureOpenAI configuration block from
appsettings.json to avoid operator confusion: delete the "AzureOpenAI" object
(the keys "ChatModel", "ChatApiKey", "ChatEndpoint") so only the "OpenAI"
settings remain; verify consumer code expects AppSettings.OpenAI (not
AppSettings.AzureOpenAI) and update any references in configuration binding or
docs to point to OpenAI-only settings.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/ResxTranslator/README.md`:
- Around line 46-47: The JSON example in README has a missing comma after the
"ApiKey" entry which makes the sample invalid; update the configuration snippet
so there is a comma separating "ApiKey": null and "ApiKey__Comment": "...", i.e.
insert the missing comma after the "ApiKey" property so the "ApiKey" and
"ApiKey__Comment" entries form valid JSON.
- Line 52: Fix the typo in the Security Note by replacing the incorrect config
filename "Bit.RexsTranslator.json" with the correct "Bit.ResxTranslator.json" in
the README.md Security Note so the environment-variable guidance references the
right config file.

---

Outside diff comments:
In `@src/ResxTranslator/README.md`:
- Line 3: The README's description for Bit.ResxTranslator still mentions "OpenAI
or Azure OpenAI" which is stale; update all occurrences (e.g., the initial
sentence containing "OpenAI or Azure OpenAI" and the other lines flagged) to
reference only "OpenAI" (remove "or Azure OpenAI" and any Azure-specific
phrasing), and scan the README for any other Azure OpenAI mentions (lines
similar to the phrase) and replace them with OpenAI-only wording to reflect the
runtime/config changes.

---

Nitpick comments:
In `@src/Websites/Platform/src/Bit.Websites.Platform.Server/appsettings.json`:
- Around line 18-29: Remove the obsolete AzureOpenAI configuration block from
appsettings.json to avoid operator confusion: delete the "AzureOpenAI" object
(the keys "ChatModel", "ChatApiKey", "ChatEndpoint") so only the "OpenAI"
settings remain; verify consumer code expects AppSettings.OpenAI (not
AppSettings.AzureOpenAI) and update any references in configuration binding or
docs to point to OpenAI-only settings.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: cdcfa09d-15fa-4b33-b207-54fcff3ae4bb

📥 Commits

Reviewing files that changed from the base of the PR and between dd28af5 and 3e149a7.

📒 Files selected for processing (18)
  • src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/AppSettings.cs
  • src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Bit.BlazorUI.Demo.Server.csproj
  • src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Startup/Services.cs
  • src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/appsettings.json
  • src/ResxTranslator/Bit.ResxTranslator/Bit.ResxTranslator.csproj
  • src/ResxTranslator/Bit.ResxTranslator/Models/ResxTranslatorSettings.cs
  • src/ResxTranslator/Bit.ResxTranslator/Program.cs
  • src/ResxTranslator/README.md
  • src/Templates/Boilerplate/Bit.Boilerplate/Bit.ResxTranslator.json
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Directory.Packages.props
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Boilerplate.Server.Api.csproj
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Program.Services.cs
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/ServerApiSettings.cs
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/appsettings.json
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Web/appsettings.json
  • src/Websites/Platform/src/Bit.Websites.Platform.Server/Bit.Websites.Platform.Server.csproj
  • src/Websites/Platform/src/Bit.Websites.Platform.Server/Startup/Services.cs
  • src/Websites/Platform/src/Bit.Websites.Platform.Server/appsettings.json
💤 Files with no reviewable changes (11)
  • src/Websites/Platform/src/Bit.Websites.Platform.Server/Bit.Websites.Platform.Server.csproj
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Web/appsettings.json
  • src/ResxTranslator/Bit.ResxTranslator/Models/ResxTranslatorSettings.cs
  • src/ResxTranslator/Bit.ResxTranslator/Program.cs
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/ServerApiSettings.cs
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Boilerplate.Server.Api.csproj
  • src/ResxTranslator/Bit.ResxTranslator/Bit.ResxTranslator.csproj
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Directory.Packages.props
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Program.Services.cs
  • src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/AppSettings.cs
  • src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Bit.BlazorUI.Demo.Server.csproj

Comment thread src/ResxTranslator/README.md Outdated
Comment thread src/ResxTranslator/README.md Outdated
yasmoradi and others added 3 commits May 26, 2026 00:28
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Yas Moradi <yas_moradi@outlook.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (3)

src/Websites/Platform/src/Bit.Websites.Platform.Server/appsettings.json:24

  • AzureOpenAI is still present in the default configuration even though the code path for Azure OpenAI has been removed in this PR. This is likely to confuse users (it suggests AzureOpenAI is still supported). Consider removing the AzureOpenAI section (and any related settings/docs) or clearly marking it as unsupported/deprecated so configuration matches runtime behavior.
            "Temperature": 1
        },
        "AzureOpenAI": {
            "ChatModel": "gpt-4.1-mini",
            "ChatApiKey": null,
            "ChatEndpoint": null
        },

src/ResxTranslator/Bit.ResxTranslator/Program.cs:68

  • After removing the Azure OpenAI code path, this exception message is now inaccurate. It should mention only the supported configuration (OpenAI) so users know which key/section is required.
else
{
    throw new InvalidOperationException("No OpenAI or Azure OpenAI API key provided.");
}

src/ResxTranslator/Bit.ResxTranslator/Bit.ResxTranslator.csproj:23

  • This project no longer references Microsoft.Extensions.AI.AzureAIInference, but Program.cs still has using Azure.AI.Inference; / using Azure.Core.Pipeline; directives. Without explicit package references those usings will fail to compile. Remove the leftover Azure usings (or add back the required Azure packages if Azure support is still intended).
    <ItemGroup>
        <PackageReference Include="Microsoft.Extensions.AI" Version="10.6.0" />
        <PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="10.6.0" />
        <PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.8" />
        <PackageReference Include="Microsoft.Extensions.Http" Version="10.0.8" />
        <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="10.0.8" />
        <PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="10.0.8" />
    </ItemGroup>

Comment thread src/ResxTranslator/README.md
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.

bit platform is using legacy Azure OpenAI package

3 participants