Skip to content

Commit

Permalink
Merge pull request #29 from cassiebreviu/main
Browse files Browse the repository at this point in the history
some code cleanup and fix default question for support flow
  • Loading branch information
cassiebreviu authored Jan 5, 2024
2 parents 3b7aa6f + bca8b21 commit 2cdc77e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
9 changes: 2 additions & 7 deletions contoso-intent/run_chat_or_support_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def run_chat_flow(question: str, customer_id: str, chat_history: [], chat_endpoi
run chat flow based on the question and customer id
"""
# call chat endpoint and return response (input is question and customer id in json format)
# TODO: Update these to secrets
url = chat_endpoint['api_base']
key = chat_endpoint['api_key']
input_data = {"question": question, "customer_id": customer_id, "chat_history": chat_history}
Expand All @@ -24,7 +23,6 @@ def run_support_flow(question: str, customer_id: str, chat_history: [], support_
run support flow based on the question and customer id
"""
# call support endpoint and return response (input is question and customer id in json format)
# TODO: Update these to secrets
url = support_endpoint['api_base']
key = support_endpoint['api_key']
input_data = {"question": question, "customer_id": customer_id, "chat_history": chat_history}
Expand All @@ -36,19 +34,16 @@ def allowSelfSignedHttps(allowed):
# bypass the server certificate verification on client side
if allowed and not os.environ.get('PYTHONHTTPSVERIFY', '') and getattr(ssl, '_create_unverified_context', None):
ssl._create_default_https_context = ssl._create_unverified_context
def call_endpoint(url, key, input_data):
def call_endpoint(url, api_key, input_data):
# Allow self-signed certificate
allowSelfSignedHttps(True) # this line is needed if you use self-signed certificate in your scoring service.
# Request data goes here
# The example below assumes JSON formatting which may be updated
# depending on the format your endpoint expects.
# More information can be found here:
# https://docs.microsoft.com/azure/machine-learning/how-to-deploy-advanced-entry-script
data = input_data
body = str.encode(json.dumps(data))
url = url
body = str.encode(json.dumps(input_data))
# Replace this with the primary/secondary key or AMLToken for the endpoint
api_key = key
if not api_key:
raise Exception("A key should be provided to invoke the endpoint")
# The azureml-model-deployment header will force the request to go to a specific deployment.
Expand Down
2 changes: 1 addition & 1 deletion contoso-support/flow.dag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ inputs:
is_chat_history: true
question:
type: string
default: the please look it up
default: What was in my last order?
is_chat_input: true
customerId:
type: string
Expand Down

0 comments on commit 2cdc77e

Please sign in to comment.