Skip to content

Commit ec9233c

Browse files
elizabethhalpermoonbox3
andauthoredOct 11, 2024··
Python: Fix AI Search Environment Variables (microsoft#9160)
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> Updating the AI Search environment variables to follow convention and match the code as it was throwing an error and unable to connect to the service as it was. It also loads in the environment properly using the dotenv package. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [X] The code builds clean without any errors or warnings - [X] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [X] All unit tests pass, and I have added new tests where possible - [X] I didn't break anyone 😄 --------- Co-authored-by: Evan Mattson <[email protected]>
1 parent dfce021 commit ec9233c

File tree

5 files changed

+13
-24
lines changed

5 files changed

+13
-24
lines changed
 

‎python/.env.example

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME=""
99
AZURE_OPENAI_ENDPOINT=""
1010
AZURE_OPENAI_API_KEY=""
1111
AZURE_OPENAI_API_VERSION=""
12-
AZURE_AISEARCH_URL=""
13-
AZURE_AISEARCH_SERVICE=""
14-
AZURE_AISEARCH_API_KEY=""
15-
AZURE_AISEARCH_INDEX_NAME=""
12+
AZURE_AI_SEARCH_ENDPOINT=""
13+
AZURE_AI_SEARCH_SERVICE=""
14+
AZURE_AI_SEARCH_API_KEY=""
15+
AZURE_AI_SEARCH_INDEX_NAME=""
1616
MONGODB_ATLAS_CONNECTION_STRING=""
1717
PINECONE_API_KEY=""
1818
PINECONE_ENVIRONMENT=""

‎python/samples/getting_started/.env.example

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ AZURE_OPENAI_TEXT_DEPLOYMENT_NAME=""
99
AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME=""
1010
AZURE_OPENAI_ENDPOINT=""
1111
AZURE_OPENAI_API_KEY=""
12-
AZURE_AISEARCH_API_KEY=""
13-
AZURE_AISEARCH_URL=""
12+
AZURE_AI_SEARCH_API_KEY=""
13+
AZURE_AI_SEARCH_ENDPOINT=""

‎python/samples/getting_started/06-memory-and-embeddings.ipynb

+3-14
Original file line numberDiff line numberDiff line change
@@ -525,17 +525,6 @@
525525
"_Please note you will need an AzureAI Search api_key or token credential and endpoint for the following example to work properly._"
526526
]
527527
},
528-
{
529-
"cell_type": "code",
530-
"execution_count": null,
531-
"id": "4eb9e2bc",
532-
"metadata": {},
533-
"outputs": [],
534-
"source": [
535-
"api_key = os.getenv(\"AZURE_AI_SEARCH_API_KEY\")\n",
536-
"endpoint = os.getenv(\"AZURE_AI_SEARCH_ENDPOINT\")"
537-
]
538-
},
539528
{
540529
"cell_type": "code",
541530
"execution_count": null,
@@ -545,7 +534,7 @@
545534
"source": [
546535
"from semantic_kernel.connectors.memory.azure_cognitive_search import AzureCognitiveSearchMemoryStore\n",
547536
"\n",
548-
"acs_memory_store = AzureCognitiveSearchMemoryStore(vector_size=1536, admin_key=api_key, search_endpoint=endpoint)\n",
537+
"acs_memory_store = AzureCognitiveSearchMemoryStore(vector_size=1536)\n",
549538
"\n",
550539
"memory = SemanticTextMemory(storage=acs_memory_store, embeddings_generator=embedding_gen)\n",
551540
"kernel.add_plugin(TextMemoryPlugin(memory), \"TextMemoryPluginACS\")"
@@ -598,7 +587,7 @@
598587
],
599588
"metadata": {
600589
"kernelspec": {
601-
"display_name": "Python 3 (ipykernel)",
590+
"display_name": "Python 3",
602591
"language": "python",
603592
"name": "python3"
604593
},
@@ -612,7 +601,7 @@
612601
"name": "python",
613602
"nbconvert_exporter": "python",
614603
"pygments_lexer": "ipython3",
615-
"version": "3.10.12"
604+
"version": "3.12.5"
616605
}
617606
},
618607
"nbformat": 4,

‎python/samples/getting_started/third_party/.env.example

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ AZURE_OPENAI_TEXT_DEPLOYMENT_NAME=""
99
AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME=""
1010
AZURE_OPENAI_ENDPOINT=""
1111
AZURE_OPENAI_API_KEY=""
12-
AZURE_AISEARCH_API_KEY=""
13-
AZURE_AISEARCH_URL=""
12+
AZURE_AI_SEARCH_API_KEY=""
13+
AZURE_AI_SEARCH_ENDPOINT=""
1414

1515
# -- WEAVIATE SETTINGS --
1616

‎python/samples/learn_resources/.env.example

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ AZURE_OPENAI_TEXT_DEPLOYMENT_NAME=""
88
AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME=""
99
AZURE_OPENAI_ENDPOINT=""
1010
AZURE_OPENAI_API_KEY=""
11-
AZURE_AISEARCH_API_KEY=""
12-
AZURE_AISEARCH_URL=""
11+
AZURE_AI_SEARCH_API_KEY=""
12+
AZURE_AI_SEARCH_ENDPOINT=""

0 commit comments

Comments
 (0)
Please sign in to comment.