@@ -15,7 +15,7 @@ def run_chat_flow(question: str, customer_id: str, chat_history: [], chat_endpoi
15
15
url = chat_endpoint ['api_base' ]
16
16
key = chat_endpoint ['api_key' ]
17
17
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' )
19
19
return response
20
20
21
21
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_
26
26
url = support_endpoint ['api_base' ]
27
27
key = support_endpoint ['api_key' ]
28
28
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' )
30
30
return response
31
31
32
32
33
33
def allowSelfSignedHttps (allowed ):
34
34
# bypass the server certificate verification on client side
35
35
if allowed and not os .environ .get ('PYTHONHTTPSVERIFY' , '' ) and getattr (ssl , '_create_unverified_context' , None ):
36
36
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 ):
38
38
# Allow self-signed certificate
39
39
allowSelfSignedHttps (True ) # this line is needed if you use self-signed certificate in your scoring service.
40
40
# Request data goes here
@@ -48,7 +48,7 @@ def call_endpoint(url, api_key, input_data):
48
48
raise Exception ("A key should be provided to invoke the endpoint" )
49
49
# The azureml-model-deployment header will force the request to go to a specific deployment.
50
50
# 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 }
52
52
req = urllib .request .Request (url , body , headers )
53
53
try :
54
54
response = urllib .request .urlopen (req )
0 commit comments