Spaces:
Runtime error
Runtime error
Greg Thompson
commited on
Commit
·
da7f4f4
1
Parent(s):
523bdca
Fix bug with accepting an integer
Browse files- app.py +5 -2
- scripts/make_request.py +21 -0
app.py
CHANGED
@@ -63,9 +63,12 @@ async def evaluate_user_message_with_nlu_api(request: Request):
|
|
63 |
|
64 |
data_dict = await request.json()
|
65 |
message_data = data_dict.get('message_data', '')
|
66 |
-
message_text = message_data['message']['text']['body']
|
67 |
|
68 |
-
|
|
|
|
|
|
|
69 |
|
70 |
if int_api_resp == 32202:
|
71 |
sentiment_api_resp = sentiment(message_text)
|
|
|
63 |
|
64 |
data_dict = await request.json()
|
65 |
message_data = data_dict.get('message_data', '')
|
66 |
+
message_text = message_data['message']['text']['body']
|
67 |
|
68 |
+
if type(message_text) == int or type(message_text) == float:
|
69 |
+
return JSONResponse(content={'type': 'integer', 'data': message_text})
|
70 |
+
|
71 |
+
int_api_resp = text2int(message_text.lower())
|
72 |
|
73 |
if int_api_resp == 32202:
|
74 |
sentiment_api_resp = sentiment(message_text)
|
scripts/make_request.py
CHANGED
@@ -78,5 +78,26 @@ request = requests.post(url=
|
|
78 |
'http://localhost:7860/nlu',
|
79 |
data=json
|
80 |
).json()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
print(request)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
'http://localhost:7860/nlu',
|
79 |
data=json
|
80 |
).json()
|
81 |
+
print(request)
|
82 |
+
|
83 |
+
json2 = 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":"eight, nine, ten"},"timestamp":1673318248,"type":"text"},"type":"message"}}\n'
|
84 |
+
|
85 |
+
|
86 |
+
request = requests.post(url=
|
87 |
+
'http://localhost:7860/nlu',
|
88 |
+
data=json2
|
89 |
+
).json()
|
90 |
|
91 |
print(request)
|
92 |
+
|
93 |
+
|
94 |
+
json2 = 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":8},"timestamp":1673318248,"type":"text"},"type":"message"}}\n'
|
95 |
+
|
96 |
+
|
97 |
+
request = requests.post(url=
|
98 |
+
'http://localhost:7860/nlu',
|
99 |
+
data=json2
|
100 |
+
).json()
|
101 |
+
|
102 |
+
print(request)
|
103 |
+
|