Skip to content

Commit a0cdfa0

Browse files
authored
Merge pull request #30 from cassiebreviu/main
Fix model deployment name in intent prompt flow
2 parents 2cdc77e + c7304c2 commit a0cdfa0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

contoso-intent/run_chat_or_support_flow.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def run_chat_flow(question: str, customer_id: str, chat_history: [], chat_endpoi
1515
url = chat_endpoint['api_base']
1616
key = chat_endpoint['api_key']
1717
input_data = {"question": question, "customer_id": customer_id, "chat_history": chat_history}
18-
response = call_endpoint(url, key, input_data)
18+
response = call_endpoint(url, key, input_data, 'contoso-chat')
1919
return response
2020

2121
def run_support_flow(question: str, customer_id: str, chat_history: [], support_endpoint) -> str:
@@ -26,15 +26,15 @@ def run_support_flow(question: str, customer_id: str, chat_history: [], support_
2626
url = support_endpoint['api_base']
2727
key = support_endpoint['api_key']
2828
input_data = {"question": question, "customer_id": customer_id, "chat_history": chat_history}
29-
response = call_endpoint(url, key, input_data)
29+
response = call_endpoint(url, key, input_data, 'contoso-support')
3030
return response
3131

3232

3333
def allowSelfSignedHttps(allowed):
3434
# bypass the server certificate verification on client side
3535
if allowed and not os.environ.get('PYTHONHTTPSVERIFY', '') and getattr(ssl, '_create_unverified_context', None):
3636
ssl._create_default_https_context = ssl._create_unverified_context
37-
def call_endpoint(url, api_key, input_data):
37+
def call_endpoint(url, api_key, input_data, model_deployment_name):
3838
# Allow self-signed certificate
3939
allowSelfSignedHttps(True) # this line is needed if you use self-signed certificate in your scoring service.
4040
# Request data goes here
@@ -48,7 +48,7 @@ def call_endpoint(url, api_key, input_data):
4848
raise Exception("A key should be provided to invoke the endpoint")
4949
# The azureml-model-deployment header will force the request to go to a specific deployment.
5050
# Remove this header to have the request observe the endpoint traffic rules
51-
headers = {'Content-Type':'application/json', 'Authorization':('Bearer '+ api_key), 'azureml-model-deployment': 'contoso-support' }
51+
headers = {'Content-Type':'application/json', 'Authorization':('Bearer '+ api_key), 'azureml-model-deployment': model_deployment_name }
5252
req = urllib.request.Request(url, body, headers)
5353
try:
5454
response = urllib.request.urlopen(req)

0 commit comments

Comments
 (0)