Skip to content

Commit be1b15f

Browse files
remove unused AZURE_OPENAI_API_KEY
1 parent 5c1e262 commit be1b15f

File tree

8 files changed

+3
-18
lines changed

8 files changed

+3
-18
lines changed
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
AZURE_AI_SEARCH_API_KEY=""
2-
AZURE_OPENAI_API_KEY=""
32

docs/workshop/docs/workshop/Challenge-3-and-4/Challenge-3.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,8 @@ One of the easiest and most fun changes you can make to the app is updating the
5757
![Azure Portal Settings > Configuration](../img/portal-app-api-env.png)
5858
5. Locate the following environment variables:
5959
- `AZURE_AI_SEARCH_API_KEY`
60-
- `AZURE_OPENAI_API_KEY`
6160
6. Copy their values and paste them into your local `\workshop\docs\workshop\.env.sample` file:
6261
`AZURE_AI_SEARCH_API_KEY=your-key-from-portal`
63-
`AZURE_OPENAI_API_KEY=your-other-key-from-portal`
6462
7. Rename the .env.sample file to .env
6563
8. Open a terminal or command prompt.
6664
9. Navigate to the project directory where `start.cmd` is located:

docs/workshop/docs/workshop/Challenge-3-and-4/knowledge_mining_api.ipynb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@
115115
" def __init__(self):\n",
116116
" self.azure_openai_deployment_model = os.getenv(\"AZURE_OPENAI_DEPLOYMENT_MODEL\")\n",
117117
" self.azure_openai_endpoint = os.getenv(\"AZURE_OPENAI_ENDPOINT\")\n",
118-
" self.azure_openai_api_key = os.getenv(\"AZURE_OPENAI_API_KEY\")\n",
119118
" self.azure_openai_api_version = os.getenv(\"AZURE_OPENAI_API_VERSION\")\n",
120119
" self.azure_ai_search_endpoint = os.getenv(\"AZURE_AI_SEARCH_ENDPOINT\")\n",
121120
" self.azure_ai_search_api_key = os.getenv(\"AZURE_AI_SEARCH_API_KEY\")\n",

docs/workshop/docs/workshop/Challenge-6/Content_safety_evaluation.ipynb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@
210210
"source": [
211211
"model_config = {\n",
212212
" \"azure_endpoint\": os.environ.get(\"AZURE_OPENAI_ENDPOINT\"),\n",
213-
" \"api_key\": os.environ.get(\"AZURE_OPENAI_API_KEY\"),\n",
214213
" \"azure_deployment\": os.environ.get(\"AZURE_OPENAI_DEPLOYMENT_MODEL\"),\n",
215214
" \"api_version\": os.environ.get(\"AZURE_OPENAI_API_VERSION\"),\n",
216215
"}"

src/api/services/history_service.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,17 @@ def init_openai_client(self):
6262
"AZURE_OPENAI_ENDPOINT or AZURE_OPENAI_RESOURCE is required")
6363

6464
endpoint = self.azure_openai_endpoint or f"https://{self.azure_openai_resource}.openai.azure.com/"
65-
api_key = self.azure_openai_api_key
6665
ad_token_provider = None
6766

68-
if not api_key:
69-
logger.debug("Using Azure AD authentication for OpenAI")
70-
ad_token_provider = get_bearer_token_provider(
71-
DefaultAzureCredential(), "https://cognitiveservices.azure.com/.default")
67+
logger.debug("Using Azure AD authentication for OpenAI")
68+
ad_token_provider = get_bearer_token_provider(
69+
DefaultAzureCredential(), "https://cognitiveservices.azure.com/.default")
7270

7371
if not self.azure_openai_deployment_name:
7472
raise ValueError("AZURE_OPENAI_MODEL is required")
7573

7674
return AsyncAzureOpenAI(
7775
api_version=self.azure_openai_api_version,
78-
api_key=api_key,
7976
azure_ad_token_provider=ad_token_provider,
8077
default_headers={"x-ms-useragent": user_agent},
8178
azure_endpoint=endpoint,

src/tests/api/common/config/test_config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ def mock_env_vars():
1313
"SQLDB_USER_MID": "test_mid",
1414
"AZURE_OPENAI_ENDPOINT": "https://openai.test",
1515
"AZURE_OPENAI_DEPLOYMENT_MODEL": "gpt-4",
16-
"AZURE_OPENAI_API_KEY": "test_key",
1716
"AZURE_OPENAI_API_VERSION": "2023-03-15-preview",
1817
"AZURE_OPENAI_RESOURCE": "test_resource",
1918
"AZURE_AI_SEARCH_ENDPOINT": "https://search.test",

src/tests/api/helpers/test_chat_helper.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ def test_process_rag_response_success(self, mock_azure_openai, mock_config):
2727

2828
# Mock the config
2929
mock_config.return_value.azure_openai_endpoint = "https://test-endpoint"
30-
mock_config.return_value.azure_openai_api_key = "test-key"
3130
mock_config.return_value.azure_openai_api_version = "2023-05-15"
3231
mock_config.return_value.azure_openai_deployment_model = "gpt-4"
3332

@@ -62,7 +61,6 @@ def test_process_rag_response_with_code_blocks(self, mock_azure_openai, mock_con
6261

6362
# Mock the config
6463
mock_config.return_value.azure_openai_endpoint = "https://test-endpoint"
65-
mock_config.return_value.azure_openai_api_key = "test-key"
6664
mock_config.return_value.azure_openai_api_version = "2023-05-15"
6765
mock_config.return_value.azure_openai_deployment_model = "gpt-4"
6866

@@ -85,7 +83,6 @@ def test_process_rag_response_error(self, mock_azure_openai, mock_config):
8583

8684
# Mock the config
8785
mock_config.return_value.azure_openai_endpoint = "https://test-endpoint"
88-
mock_config.return_value.azure_openai_api_key = "test-key"
8986
mock_config.return_value.azure_openai_api_version = "2023-05-15"
9087

9188
# Test the function
@@ -110,7 +107,6 @@ def test_process_rag_response_invalid_json(self, mock_azure_openai, mock_config)
110107

111108
# Mock the config
112109
mock_config.return_value.azure_openai_endpoint = "https://test-endpoint"
113-
mock_config.return_value.azure_openai_api_key = "test-key"
114110
mock_config.return_value.azure_openai_api_version = "2023-05-15"
115111

116112
# Test the function

src/tests/api/services/test_history_service.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ def test_init(self, history_service, mock_config_instance):
5757
assert history_service.azure_cosmosdb_database == mock_config_instance.azure_cosmosdb_database
5858
assert history_service.azure_cosmosdb_account == mock_config_instance.azure_cosmosdb_account
5959
assert history_service.azure_openai_endpoint == mock_config_instance.azure_openai_endpoint
60-
assert history_service.azure_openai_api_key == mock_config_instance.azure_openai_api_key
6160
assert history_service.chat_history_enabled
6261

6362
def test_init_cosmosdb_client_enabled(self, history_service):
@@ -106,7 +105,6 @@ def test_init_openai_client_no_deployment_name(self, history_service):
106105

107106
def test_init_openai_client_no_api_key(self, history_service):
108107
"""Test OpenAI client initialization with no API key"""
109-
history_service.azure_openai_api_key = None
110108
with patch("services.history_service.get_bearer_token_provider", return_value="token_provider"):
111109
with patch("services.history_service.AsyncAzureOpenAI", return_value="openai_client"):
112110
client = history_service.init_openai_client()

0 commit comments

Comments
 (0)