Skip to content

Commit

Permalink
Python: Fix AI Search Environment Variables (#9160)
Browse files Browse the repository at this point in the history
### 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]>
  • Loading branch information
elizabethhalper and moonbox3 authored Oct 11, 2024
1 parent dfce021 commit ec9233c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 24 deletions.
8 changes: 4 additions & 4 deletions python/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME=""
AZURE_OPENAI_ENDPOINT=""
AZURE_OPENAI_API_KEY=""
AZURE_OPENAI_API_VERSION=""
AZURE_AISEARCH_URL=""
AZURE_AISEARCH_SERVICE=""
AZURE_AISEARCH_API_KEY=""
AZURE_AISEARCH_INDEX_NAME=""
AZURE_AI_SEARCH_ENDPOINT=""
AZURE_AI_SEARCH_SERVICE=""
AZURE_AI_SEARCH_API_KEY=""
AZURE_AI_SEARCH_INDEX_NAME=""
MONGODB_ATLAS_CONNECTION_STRING=""
PINECONE_API_KEY=""
PINECONE_ENVIRONMENT=""
Expand Down
4 changes: 2 additions & 2 deletions python/samples/getting_started/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ AZURE_OPENAI_TEXT_DEPLOYMENT_NAME=""
AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME=""
AZURE_OPENAI_ENDPOINT=""
AZURE_OPENAI_API_KEY=""
AZURE_AISEARCH_API_KEY=""
AZURE_AISEARCH_URL=""
AZURE_AI_SEARCH_API_KEY=""
AZURE_AI_SEARCH_ENDPOINT=""
17 changes: 3 additions & 14 deletions python/samples/getting_started/06-memory-and-embeddings.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -525,17 +525,6 @@
"_Please note you will need an AzureAI Search api_key or token credential and endpoint for the following example to work properly._"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4eb9e2bc",
"metadata": {},
"outputs": [],
"source": [
"api_key = os.getenv(\"AZURE_AI_SEARCH_API_KEY\")\n",
"endpoint = os.getenv(\"AZURE_AI_SEARCH_ENDPOINT\")"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -545,7 +534,7 @@
"source": [
"from semantic_kernel.connectors.memory.azure_cognitive_search import AzureCognitiveSearchMemoryStore\n",
"\n",
"acs_memory_store = AzureCognitiveSearchMemoryStore(vector_size=1536, admin_key=api_key, search_endpoint=endpoint)\n",
"acs_memory_store = AzureCognitiveSearchMemoryStore(vector_size=1536)\n",
"\n",
"memory = SemanticTextMemory(storage=acs_memory_store, embeddings_generator=embedding_gen)\n",
"kernel.add_plugin(TextMemoryPlugin(memory), \"TextMemoryPluginACS\")"
Expand Down Expand Up @@ -598,7 +587,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
Expand All @@ -612,7 +601,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.12.5"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions python/samples/getting_started/third_party/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ AZURE_OPENAI_TEXT_DEPLOYMENT_NAME=""
AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME=""
AZURE_OPENAI_ENDPOINT=""
AZURE_OPENAI_API_KEY=""
AZURE_AISEARCH_API_KEY=""
AZURE_AISEARCH_URL=""
AZURE_AI_SEARCH_API_KEY=""
AZURE_AI_SEARCH_ENDPOINT=""

# -- WEAVIATE SETTINGS --

Expand Down
4 changes: 2 additions & 2 deletions python/samples/learn_resources/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ AZURE_OPENAI_TEXT_DEPLOYMENT_NAME=""
AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME=""
AZURE_OPENAI_ENDPOINT=""
AZURE_OPENAI_API_KEY=""
AZURE_AISEARCH_API_KEY=""
AZURE_AISEARCH_URL=""
AZURE_AI_SEARCH_API_KEY=""
AZURE_AI_SEARCH_ENDPOINT=""

0 comments on commit ec9233c

Please sign in to comment.