Spaces:
Build error
Build error
Greg Thompson
commited on
Commit
•
82e3c2a
1
Parent(s):
da7f4f4
Comment /nlu endpoint function
Browse files
app.py
CHANGED
@@ -65,11 +65,14 @@ async def evaluate_user_message_with_nlu_api(request: Request):
|
|
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)
|
75 |
# [{'label': 'POSITIVE', 'score': 0.991188645362854}]
|
|
|
65 |
message_data = data_dict.get('message_data', '')
|
66 |
message_text = message_data['message']['text']['body']
|
67 |
|
68 |
+
# Handles if a student answer is already an integer or a float
|
69 |
if type(message_text) == int or type(message_text) == float:
|
70 |
return JSONResponse(content={'type': 'integer', 'data': message_text})
|
71 |
|
72 |
+
# Checks the student answer and returns an integer
|
73 |
int_api_resp = text2int(message_text.lower())
|
74 |
|
75 |
+
# '32202' is text2int's error code for non-integer student answers (ie., "I don't know")
|
76 |
if int_api_resp == 32202:
|
77 |
sentiment_api_resp = sentiment(message_text)
|
78 |
# [{'label': 'POSITIVE', 'score': 0.991188645362854}]
|