Spaces:
Build error
Build error
update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,7 @@ or
|
|
| 4 |
`python -m uvicorn app:app --reload --host localhost --port 7860`
|
| 5 |
"""
|
| 6 |
import ast
|
|
|
|
| 7 |
import mathactive.microlessons.num_one as num_one_quiz
|
| 8 |
from fastapi import FastAPI, Request
|
| 9 |
from fastapi.responses import JSONResponse
|
|
@@ -18,6 +19,11 @@ from mathtext_fastapi.conversation_manager import manage_conversation_response
|
|
| 18 |
from mathtext_fastapi.v2_conversation_manager import manage_conversation_response
|
| 19 |
from mathtext_fastapi.nlu import evaluate_message_with_nlu
|
| 20 |
from mathtext_fastapi.nlu import run_intent_classification
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
app = FastAPI()
|
| 23 |
|
|
@@ -163,7 +169,7 @@ async def num_one(request: Request):
|
|
| 163 |
}
|
| 164 |
"""
|
| 165 |
data_dict = await request.json()
|
| 166 |
-
message_data =
|
| 167 |
user_id = message_data['user_id']
|
| 168 |
message_text = message_data['message_text']
|
| 169 |
return num_one_quiz.process_user_message(user_id, message_text)
|
|
|
|
| 4 |
`python -m uvicorn app:app --reload --host localhost --port 7860`
|
| 5 |
"""
|
| 6 |
import ast
|
| 7 |
+
import json
|
| 8 |
import mathactive.microlessons.num_one as num_one_quiz
|
| 9 |
from fastapi import FastAPI, Request
|
| 10 |
from fastapi.responses import JSONResponse
|
|
|
|
| 19 |
from mathtext_fastapi.v2_conversation_manager import manage_conversation_response
|
| 20 |
from mathtext_fastapi.nlu import evaluate_message_with_nlu
|
| 21 |
from mathtext_fastapi.nlu import run_intent_classification
|
| 22 |
+
from sentry_sdk.utils import BadDsn
|
| 23 |
+
try:
|
| 24 |
+
from scripts import logger
|
| 25 |
+
except BadDsn:
|
| 26 |
+
pass
|
| 27 |
|
| 28 |
app = FastAPI()
|
| 29 |
|
|
|
|
| 169 |
}
|
| 170 |
"""
|
| 171 |
data_dict = await request.json()
|
| 172 |
+
message_data = json.loads(data_dict.get('message_data', '').get('message_body', '').replace("'", '"'))
|
| 173 |
user_id = message_data['user_id']
|
| 174 |
message_text = message_data['message_text']
|
| 175 |
return num_one_quiz.process_user_message(user_id, message_text)
|