Skip to content

Commit 1658a3a

Browse files
authored
Updated constructor
AutoSuggestClient does not take the generic endpoint anymore. Reconfigured it to take the user's endpoint. Also added 'os' to import list.
1 parent deb4483 commit 1658a3a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

samples/search/autosuggest_samples.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import os
2+
13
from azure.cognitiveservices.search.autosuggest import AutoSuggestClient
24
from azure.cognitiveservices.search.autosuggest.models import (
35
Suggestions,
@@ -8,16 +10,16 @@
810
from msrest.authentication import CognitiveServicesCredentials
911

1012
# Add your Bing Autosuggest subscription key to your environment variables.
11-
SUBSCRIPTION_KEY= os.environ['BING_AUTOSUGGEST_SUBSCRIPTION_KEY']
12-
13+
SUBSCRIPTION_KEY = os.environ['BING_AUTOSUGGEST_SUBSCRIPTION_KEY']
14+
ENDPOINT = os.environ['BING_AUTOSUGGEST_ENDPOINT']
1315

1416
def autosuggest_lookup(subscription_key):
1517
"""AutoSuggestLookup.
1618
1719
This will look up a single query (Xbox) and print out name and url for first web result.
1820
"""
1921
client = AutoSuggestClient(
20-
endpoint="https://api.cognitive.microsoft.com",
22+
endpoint=ENDPOINT,
2123
credentials=CognitiveServicesCredentials(subscription_key)
2224
)
2325

@@ -49,7 +51,7 @@ def error(subscription_key):
4951

5052
# Breaking the subscription key on purpose
5153
client = AutoSuggestClient(
52-
endpoint="https://api.cognitive.microsoft.com",
54+
endpoint=ENDPOINT,
5355
credentials=CognitiveServicesCredentials(subscription_key+"1")
5456
)
5557

0 commit comments

Comments
 (0)