Skip to content

Commit

Permalink
[repo] fix: removed HTTPS requirement for AOAI Embeddings (#1694)
Browse files Browse the repository at this point in the history
## Linked issues

closes: #1688

## Details

Removed HTTPS url requirement from JS, C#, and Python.

## 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
  • Loading branch information
lilyydu authored May 30, 2024
1 parent aa430b8 commit df61246
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ public AzureOpenAIEmbeddingsOptions(
Verify.ParamNotNull(azureEndpoint);

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

this.AzureApiKey = azureApiKey;
this.AzureDeployment = azureDeployment;
Expand Down
6 changes: 0 additions & 6 deletions js/packages/teams-ai/src/embeddings/OpenAIEmbeddings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,6 @@ export class OpenAIEmbeddings implements EmbeddingsModel {
endpoint = endpoint.substring(0, endpoint.length - 1);
}

if (!endpoint.toLowerCase().startsWith('https://')) {
throw new Error(
`Client created with an invalid endpoint of '${endpoint}'. The endpoint must be a valid HTTPS url.`
);
}

this.options.azureEndpoint = endpoint;
} else {
this._useAzure = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ def __init__(self, options: AzureOpenAIEmbeddingsOptions, log=Logger("teams.ai")
if endpoint[-1] == "/":
endpoint = endpoint[0 : (len(endpoint) - 1)]

if not endpoint.lower().startswith("https://"):
raise ValueError(f"""
Client created with an invalid endpoint of \"{endpoint}\".
The endpoint must be a valid HTTPS url.
""")

self.options.azure_endpoint = endpoint

async def create_embeddings(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import httpx
import openai
import pytest

from teams.ai.embeddings.azure_openai_embeddings import AzureOpenAIEmbeddings
from teams.ai.embeddings.azure_openai_embeddings_options import (
Expand Down Expand Up @@ -93,7 +92,6 @@ class TestOpenAIEmbeddings(IsolatedAsyncioTestCase):
embeddings: AzureOpenAIEmbeddings
options_with_array: AzureOpenAIEmbeddingsOptions
embeddings_with_array: AzureOpenAIEmbeddings
options_error: AzureOpenAIEmbeddingsOptions

def setUp(self):
self.options = AzureOpenAIEmbeddingsOptions(
Expand All @@ -103,13 +101,6 @@ def setUp(self):
log_requests=True,
retry_policy=[2, 4],
)
self.options_error = AzureOpenAIEmbeddingsOptions(
azure_api_key="empty",
azure_endpoint="www.mock.openai.azure.com/",
azure_deployment="text-embedding-ada-002",
log_requests=True,
retry_policy=[2, 4],
)
self.options_with_array = AzureOpenAIEmbeddingsOptions(
azure_api_key="empty",
azure_endpoint="https://mock.openai.azure.com",
Expand All @@ -122,10 +113,6 @@ def setUp(self):
},
)

async def test_endpoint_error(self):
with pytest.raises(ValueError):
AzureOpenAIEmbeddings(self.options_error)

@mock.patch("openai.AsyncAzureOpenAI", return_value=MockAsyncAzureOpenAI)
async def test_string_embedding(self, mock_async_azure_open_ai):
self.embeddings = AzureOpenAIEmbeddings(self.options)
Expand Down

0 comments on commit df61246

Please sign in to comment.