Spaces:
Build error
Build error
Greg Thompson
commited on
Commit
•
20f623d
1
Parent(s):
a34228d
Update nlu endpoint logic
Browse files- mathtext_fastapi/nlu.py +8 -9
mathtext_fastapi/nlu.py
CHANGED
@@ -155,15 +155,14 @@ def evaluate_message_with_nlu(message_data):
|
|
155 |
predicted_label = predict_message_intent(message_text)
|
156 |
if predicted_label['confidence'] > 0.01:
|
157 |
nlu_response = predicted_label
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
)
|
167 |
else:
|
168 |
nlu_response = build_nlu_response_object(
|
169 |
'integer',
|
|
|
155 |
predicted_label = predict_message_intent(message_text)
|
156 |
if predicted_label['confidence'] > 0.01:
|
157 |
nlu_response = predicted_label
|
158 |
+
else:
|
159 |
+
# Run sentiment analysis
|
160 |
+
sentiment_api_resp = sentiment(message_text)
|
161 |
+
nlu_response = build_nlu_response_object(
|
162 |
+
'sentiment',
|
163 |
+
sentiment_api_resp[0]['label'],
|
164 |
+
sentiment_api_resp[0]['score']
|
165 |
+
)
|
|
|
166 |
else:
|
167 |
nlu_response = build_nlu_response_object(
|
168 |
'integer',
|