You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
system:
You are a nutrition specialist.
user:
{{question}}
[{"system_metrics": {"completion_tokens": 61,"duration": 6.065642,"prompt_tokens": 30,"total_tokens": 91},"output": "In 100 grams of banana, you will find:\n\n- Carbohydrates: Approximately 23g\n- Protein: Approximately 1.1g\n- Fat: Approximately 0.3g\n\nPlease note, specific nutritional content might vary slightly based on the size and ripeness of the banana."}]
Deploying the flow for real time inference
importurllib.requestimportjsonimportosimportssldefallowSelfSignedHttps(allowed):
ifallowedandnotos.environ.get('PYTHONHTTPSVERIFY', '') andgetattr(ssl, '_create_unverified_context', None):
ssl._create_default_https_context=ssl._create_unverified_contextallowSelfSignedHttps(True)
data= {
"food": "<food goes here>",
}
body=str.encode(json.dumps(data))
url='<endpoint url goes here>'api_key='<api key goes here>'ifnotapi_key:
raiseException("A key should be provided to invoke the endpoint")
headers= {'Content-Type':'application/json', 'Authorization':('Bearer '+api_key), 'azureml-model-deployment': 'blue' }
req=urllib.request.Request(url, body, headers)
try:
response=urllib.request.urlopen(req)
result=response.read()
print(result)
excepturllib.error.HTTPErroraserror:
print("The request failed with status code: "+str(error.code))
print(error.info())
print(error.read().decode("utf8", 'ignore'))