Skip to content

Commit a9fb94f

Browse files
authored
[repo] fix: removed HTTPS client requirement (#1718)
## Linked issues closes: #1698 ## Details - removed client check HTTPS error throwing ## Attestation Checklist - [x] My code follows the style guidelines of this project - I have checked for/fixed spelling, linting, and other errors - I have commented my code for clarity - I have made corresponding changes to the documentation (updating the doc strings in the code is sufficient) - My changes generate no new warnings - I have added tests that validates my changes, and provides sufficient test coverage. I have tested with: - Local testing - E2E testing in Teams - New and existing unit tests pass locally with my changes
1 parent 46ff7e5 commit a9fb94f

File tree

7 files changed

+1
-51
lines changed

7 files changed

+1
-51
lines changed

dotnet/packages/Microsoft.TeamsAI/Microsoft.TeamsAI.Tests/AITests/Models/OpenAIModelTests.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,6 @@ public void Test_Constructor_OpenAI()
2828
new OpenAIModel(options);
2929
}
3030

31-
[Fact]
32-
public void Test_Constructor_AzureOpenAI_InvalidAzureEndpoint()
33-
{
34-
// Arrange
35-
var options = new AzureOpenAIModelOptions("test-key", "test-deployment", "https://test.openai.azure.com/");
36-
options.AzureEndpoint = "test-endpoint";
37-
38-
// Act
39-
Exception exception = Assert.Throws<ArgumentException>(() => new OpenAIModel(options));
40-
41-
// Assert
42-
Assert.Equal("Model created with an invalid endpoint of `test-endpoint`. The endpoint must be a valid HTTPS url.", exception.Message);
43-
}
44-
4531
[Fact]
4632
public void Test_Constructor_AzureOpenAI_InvalidAzureApiVersion()
4733
{

dotnet/packages/Microsoft.TeamsAI/Microsoft.TeamsAI/AI/Embeddings/OpenAIEmbeddings.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,7 @@ public OpenAIEmbeddings(AzureOpenAIEmbeddingsOptions options, ILoggerFactory? lo
7575
Verify.ParamNotNull(options.AzureApiKey, "AzureOpenAIEmbeddingsOptions.AzureApiKey");
7676
Verify.ParamNotNull(options.AzureDeployment, "AzureOpenAIEmbeddingsOptions.AzureDeployment");
7777
Verify.ParamNotNull(options.AzureEndpoint, "AzureOpenAIEmbeddingsOptions.AzureEndpoint");
78-
if (!options.AzureEndpoint.StartsWith("https://"))
79-
{
80-
throw new ArgumentException($"Model created with an invalid endpoint of `{options.AzureEndpoint}`. The endpoint must be a valid HTTPS url.");
81-
}
78+
8279
string apiVersion = options.AzureApiVersion ?? "2023-05-15";
8380
ServiceVersion? serviceVersion = ConvertStringToServiceVersion(apiVersion);
8481
if (serviceVersion == null)

dotnet/packages/Microsoft.TeamsAI/Microsoft.TeamsAI/AI/Models/AzureOpenAIModelOptions.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ public AzureOpenAIModelOptions(
4444
Verify.ParamNotNull(azureEndpoint);
4545

4646
azureEndpoint = azureEndpoint.Trim();
47-
if (!azureEndpoint.StartsWith("https://"))
48-
{
49-
throw new ArgumentException($"Model created with an invalid endpoint of `{azureEndpoint}`. The endpoint must be a valid HTTPS url.");
50-
}
5147

5248
this.AzureApiKey = azureApiKey;
5349
this.AzureDefaultDeployment = azureDefaultDeployment;

dotnet/packages/Microsoft.TeamsAI/Microsoft.TeamsAI/AI/Models/OpenAIModel.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,6 @@ public OpenAIModel(AzureOpenAIModelOptions options, ILoggerFactory? loggerFactor
9191
Verify.ParamNotNull(options.AzureApiKey, "AzureOpenAIModelOptions.AzureApiKey");
9292
Verify.ParamNotNull(options.AzureDefaultDeployment, "AzureOpenAIModelOptions.AzureDefaultDeployment");
9393
Verify.ParamNotNull(options.AzureEndpoint, "AzureOpenAIModelOptions.AzureEndpoint");
94-
if (!options.AzureEndpoint.StartsWith("https://"))
95-
{
96-
throw new ArgumentException($"Model created with an invalid endpoint of `{options.AzureEndpoint}`. The endpoint must be a valid HTTPS url.");
97-
}
9894
string apiVersion = options.AzureApiVersion ?? "2024-02-15-preview";
9995
ServiceVersion? serviceVersion = ConvertStringToServiceVersion(apiVersion);
10096
if (serviceVersion == null)

js/packages/teams-ai/src/internals/OpenAIClient.spec.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ describe('OpenAIClient', () => {
1414
const options: OpenAIClientOptions = {
1515
apiKey: 'mock-key'
1616
};
17-
const optionsWithInvalidEndpoint: OpenAIClientOptions = {
18-
apiKey: 'mock-key',
19-
endpoint: 'www.'
20-
};
2117
const optionsWithEmptyAPIKey: OpenAIClientOptions = {
2218
apiKey: ''
2319
};
@@ -106,15 +102,6 @@ describe('OpenAIClient', () => {
106102
assert.equal(openAIClient.options.apiKey, options.apiKey);
107103
});
108104

109-
it('should throw error due to invalid endpoint', () => {
110-
assert.throws(
111-
() => new OpenAIClient(optionsWithInvalidEndpoint),
112-
new Error(
113-
`OpenAIClient initialized with an invalid endpoint of '${optionsWithInvalidEndpoint.endpoint}'. The endpoint must be a valid HTTPS url.`
114-
)
115-
);
116-
});
117-
118105
it('should throw error due to invalid api key', () => {
119106
assert.throws(
120107
() => new OpenAIClient(optionsWithEmptyAPIKey),

js/packages/teams-ai/src/internals/OpenAIClient.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,6 @@ export class OpenAIClient {
5757
if (options.endpoint.endsWith('/')) {
5858
options.endpoint = options.endpoint.substring(0, options.endpoint.length - 1);
5959
}
60-
61-
if (!options.endpoint.toLowerCase().startsWith('https://')) {
62-
throw new Error(
63-
`OpenAIClient initialized with an invalid endpoint of '${options.endpoint}'. The endpoint must be a valid HTTPS url.`
64-
);
65-
}
6660
}
6761

6862
// Validate API key

js/packages/teams-ai/src/models/OpenAIModel.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,6 @@ export class OpenAIModel implements PromptCompletionModel {
188188
endpoint = endpoint.substring(0, endpoint.length - 1);
189189
}
190190

191-
if (!endpoint.toLowerCase().startsWith('https://')) {
192-
throw new Error(
193-
`Model created with an invalid endpoint of '${endpoint}'. The endpoint must be a valid HTTPS url.`
194-
);
195-
}
196-
197191
this.options.azureEndpoint = endpoint;
198192
} else {
199193
this._useAzure = false;

0 commit comments

Comments
 (0)