test(copilot): expand unit tests for AI model providers #1928
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Checklist
If you have any questions, you can refer to the Contributing Guide
What is the current behavior?
Currently, MQTTX Copilot does not support using Azure OpenAI as an AI service provider. Users are limited to the existing providers like OpenAI, Google, Anthropic, etc.
Issue Number
What is the new behavior?
This PR introduces support for Azure OpenAI within MQTTX Copilot, allowing users to configure and utilize their Azure OpenAI deployments.
?api-version=...
) to the API Host field.deployment-
when entered in the "Model" field.@ai-sdk/azure
.Does this PR introduce a breaking change?
Specific Instructions
Are there any specific instructions or things that should be known before review?
Azure OpenAI Integration Notes:
https://your-resource.openai.azure.com/
) OR "Resource Name" (e.g.,your-resource
) should be entered into the existing "API Host" field in the settings.2025-01-01-preview
) must be appended as a query parameter to the URL/Resource Name entered in the "API Host" field. Example:https://your-resource.openai.azure.com/?api-version=2025-01-01-preview
oryour-resource?api-version=2025-01-01-preview
.getAzureProviderOptions
helper function insrc/utils/ai/copilot.ts
parses theapi-version
from thebaseURL
string.deployment-
when entered into the "Model" field (e.g.,deployment-gpt-4o
).determineProviderType
logic inAIAgent.ts
without needing a separate "Provider" field tied to the model selection. TheprocessModel
function inAIAgent.ts
handles stripping this prefix before passing the actual deployment name to the Azure SDK.scripts/patch-azure-sdk.js
(run viapostinstall
) to fix an upstream dependency resolution issue in@ai-sdk/azure
related to@ai-sdk/openai/internal
.?api-version=...
) and "Model" (using thedeployment-
prefix) fields for Azure OpenAI. Reference: Azure OpenAI.tests/unit/utils/ai/copilot.spec.ts
have been updated to cover the Azure OpenAI provider instantiation and the handling of its specific configuration parameters. Tests for other providers have also been made more explicit.Other information
This implementation relies on parsing the API version from the user-provided Base URL/API Host string and uses a naming convention (
deployment-
prefix) for Azure models to integrate with the existing system structure with minimal disruption. Ensure UI labels/placeholders clearly guide the user on these specific Azure configuration steps.