Greg Thompson commited on
Commit
fe10a08
1 Parent(s): 64c0031

Update nlu_response for sentiment label

Browse files
Files changed (2) hide show
  1. app.py +1 -1
  2. scripts/make_request.py +10 -0
app.py CHANGED
@@ -95,7 +95,7 @@ async def evaluate_user_message_with_nlu_api(request: Request):
95
  sentiment_api_resp = sentiment(message_text)
96
  # [{'label': 'POSITIVE', 'score': 0.991188645362854}]
97
  sent_data_dict = {'type': 'sentiment', 'data': sentiment_api_resp[0]['label']}
98
- nlu_response = {'type': 'sentiment', 'data': 'negative', 'confidence': sentiment_api_resp[0]['score']}
99
  else:
100
  if len(student_response_arr) > 1:
101
  nlu_response = {'type': 'integer', 'data': ','.join(str(num) for num in student_response_arr), 'confidence': ''}
 
95
  sentiment_api_resp = sentiment(message_text)
96
  # [{'label': 'POSITIVE', 'score': 0.991188645362854}]
97
  sent_data_dict = {'type': 'sentiment', 'data': sentiment_api_resp[0]['label']}
98
+ nlu_response = {'type': 'sentiment', 'data': sentiment_api_resp[0]['label'], 'confidence': sentiment_api_resp[0]['score']}
99
  else:
100
  if len(student_response_arr) > 1:
101
  nlu_response = {'type': 'integer', 'data': ','.join(str(num) for num in student_response_arr), 'confidence': ''}
scripts/make_request.py CHANGED
@@ -114,6 +114,16 @@ print(request)
114
 
115
  json = b'{"message_data": {"message":{"_vnd":{"v1":{"author":{"id":57787919091,"name":"GT","type":"OWNER"},"card_uuid":null,"chat":{"assigned_to":{"id":"jhk151kl-hj42-3752-3hjk-h4jk6hjkk2","name":"Greg Thompson","type":"OPERATOR"},"contact_uuid":"j43hk26-2hjl-43jk-hnk2-k4ljl46j0ds09","inserted_at":"2022-07-05T04:00:34.033522Z","owner":"+57787919091","permalink":"https://app.turn.io/c/4kl209sd0-a7b8-2hj3-8563-3hu4a89b32","state":"OPEN","state_reason":"Re-opened by inbound message.","unread_count":14,"updated_at":"2023-01-10T02:37:28.487319Z","uuid":"4kl209sd0-a7b8-2hj3-8563-3hu4a89b32"},"direction":"inbound","faq_uuid":null,"in_reply_to":null,"inserted_at":"2023-01-10T02:37:28.477940Z","labels":[{"confidence":0.506479332,"metadata":{"nlu":{"confidence":0.506479332,"intent":"question","model_name":"nlu-general-spacy-ngrams-20191014"}},"uuid":"ha7890s2k-hjk2-2476-s8d9-fh9779a8a9ds","value":"Unclassified"}],"last_status":null,"last_status_timestamp":null,"on_fallback_channel":false,"rendered_content":null,"uuid":"s8df79zhws-h89s-hj23-7s8d-thb248d9bh2qn"}},"from":57787919091,"id":"hsjkthzZGehkzs09sijWA3","text":{"body":"I dont know"},"timestamp":1673318248,"type":"text"},"type":"message"}}\n'
116
 
 
 
 
 
 
 
 
 
 
 
117
  # "8, 9, 10" > "8,9,10"
118
  request = requests.post(url=
119
  'http://localhost:7860/nlu',
 
114
 
115
  json = b'{"message_data": {"message":{"_vnd":{"v1":{"author":{"id":57787919091,"name":"GT","type":"OWNER"},"card_uuid":null,"chat":{"assigned_to":{"id":"jhk151kl-hj42-3752-3hjk-h4jk6hjkk2","name":"Greg Thompson","type":"OPERATOR"},"contact_uuid":"j43hk26-2hjl-43jk-hnk2-k4ljl46j0ds09","inserted_at":"2022-07-05T04:00:34.033522Z","owner":"+57787919091","permalink":"https://app.turn.io/c/4kl209sd0-a7b8-2hj3-8563-3hu4a89b32","state":"OPEN","state_reason":"Re-opened by inbound message.","unread_count":14,"updated_at":"2023-01-10T02:37:28.487319Z","uuid":"4kl209sd0-a7b8-2hj3-8563-3hu4a89b32"},"direction":"inbound","faq_uuid":null,"in_reply_to":null,"inserted_at":"2023-01-10T02:37:28.477940Z","labels":[{"confidence":0.506479332,"metadata":{"nlu":{"confidence":0.506479332,"intent":"question","model_name":"nlu-general-spacy-ngrams-20191014"}},"uuid":"ha7890s2k-hjk2-2476-s8d9-fh9779a8a9ds","value":"Unclassified"}],"last_status":null,"last_status_timestamp":null,"on_fallback_channel":false,"rendered_content":null,"uuid":"s8df79zhws-h89s-hj23-7s8d-thb248d9bh2qn"}},"from":57787919091,"id":"hsjkthzZGehkzs09sijWA3","text":{"body":"I dont know"},"timestamp":1673318248,"type":"text"},"type":"message"}}\n'
116
 
117
+ # "8, 9, 10" > "8,9,10"
118
+ request = requests.post(url=
119
+ 'http://localhost:7860/nlu',
120
+ data=json
121
+ ).json()
122
+
123
+ print(request)
124
+
125
+ json = b'{"message_data": {"message":{"_vnd":{"v1":{"author":{"id":57787919091,"name":"GT","type":"OWNER"},"card_uuid":null,"chat":{"assigned_to":{"id":"jhk151kl-hj42-3752-3hjk-h4jk6hjkk2","name":"Greg Thompson","type":"OPERATOR"},"contact_uuid":"j43hk26-2hjl-43jk-hnk2-k4ljl46j0ds09","inserted_at":"2022-07-05T04:00:34.033522Z","owner":"+57787919091","permalink":"https://app.turn.io/c/4kl209sd0-a7b8-2hj3-8563-3hu4a89b32","state":"OPEN","state_reason":"Re-opened by inbound message.","unread_count":14,"updated_at":"2023-01-10T02:37:28.487319Z","uuid":"4kl209sd0-a7b8-2hj3-8563-3hu4a89b32"},"direction":"inbound","faq_uuid":null,"in_reply_to":null,"inserted_at":"2023-01-10T02:37:28.477940Z","labels":[{"confidence":0.506479332,"metadata":{"nlu":{"confidence":0.506479332,"intent":"question","model_name":"nlu-general-spacy-ngrams-20191014"}},"uuid":"ha7890s2k-hjk2-2476-s8d9-fh9779a8a9ds","value":"Unclassified"}],"last_status":null,"last_status_timestamp":null,"on_fallback_channel":false,"rendered_content":null,"uuid":"s8df79zhws-h89s-hj23-7s8d-thb248d9bh2qn"}},"from":57787919091,"id":"hsjkthzZGehkzs09sijWA3","text":{"body":"Today is a wonderful day"},"timestamp":1673318248,"type":"text"},"type":"message"}}\n'
126
+
127
  # "8, 9, 10" > "8,9,10"
128
  request = requests.post(url=
129
  'http://localhost:7860/nlu',