Spaces:
Runtime error
Runtime error
update app module endpoints
Browse files
app.py
CHANGED
@@ -103,7 +103,7 @@ async def evaluate_user_message_with_nlu_api(request: Request):
|
|
103 |
message_data = data_dict.get('message_data', '')
|
104 |
nlu_response = evaluate_message_with_nlu(message_data)
|
105 |
return JSONResponse(content=nlu_response)
|
106 |
-
|
107 |
|
108 |
@app.post("/question")
|
109 |
async def ask_math_question(request: Request):
|
@@ -113,14 +113,15 @@ async def ask_math_question(request: Request):
|
|
113 |
request.body: json - amount of correct and incorrect answers in the account
|
114 |
{
|
115 |
'number_correct': 0,
|
116 |
-
'number_incorrect': 0
|
|
|
117 |
}
|
118 |
|
119 |
Output
|
120 |
context: dict - the information for the current state
|
121 |
{
|
122 |
'text': 'What is 1+2?',
|
123 |
-
'question_numbers': [1,2,3
|
124 |
'right_answer': 3,
|
125 |
'number_correct': 0,
|
126 |
'number_incorrect': 0,
|
@@ -131,8 +132,9 @@ async def ask_math_question(request: Request):
|
|
131 |
message_data = ast.literal_eval(data_dict.get('message_data', '').get('message_body', ''))
|
132 |
number_correct = message_data['number_correct']
|
133 |
number_incorrect = message_data['number_incorrect']
|
|
|
134 |
|
135 |
-
return JSONResponse(start_interactive_math(number_correct, number_incorrect))
|
136 |
|
137 |
|
138 |
@app.post("/hint")
|
@@ -142,11 +144,11 @@ async def get_hint(request: Request):
|
|
142 |
Input
|
143 |
request.body: json - amount of correct and incorrect answers in the account
|
144 |
{
|
145 |
-
'question_numbers': [1,2,3
|
146 |
'right_answer': 3,
|
147 |
-
'user_answer': 10,
|
148 |
'number_correct': 0,
|
149 |
'number_incorrect': 0,
|
|
|
150 |
'hints_used': 0
|
151 |
}
|
152 |
|
@@ -154,19 +156,21 @@ async def get_hint(request: Request):
|
|
154 |
context: dict - the information for the current state
|
155 |
{
|
156 |
'text': 'What is 1+2?',
|
157 |
-
'question_numbers': [1,2,3], #
|
158 |
'right_answer': 3,
|
159 |
'number_correct': 0,
|
160 |
'number_incorrect': 0,
|
|
|
161 |
'hints_used': 0
|
162 |
}
|
163 |
"""
|
164 |
data_dict = await request.json()
|
165 |
message_data = ast.literal_eval(data_dict.get('message_data', '').get('message_body', ''))
|
166 |
-
question_numbers = message_data['
|
167 |
-
|
168 |
number_correct = message_data['number_correct']
|
169 |
number_incorrect = message_data['number_incorrect']
|
|
|
170 |
hints_used = message_data['hints_used']
|
171 |
|
172 |
-
return JSONResponse(generate_hint(question_numbers, number_correct, number_incorrect, hints_used))
|
|
|
103 |
message_data = data_dict.get('message_data', '')
|
104 |
nlu_response = evaluate_message_with_nlu(message_data)
|
105 |
return JSONResponse(content=nlu_response)
|
106 |
+
|
107 |
|
108 |
@app.post("/question")
|
109 |
async def ask_math_question(request: Request):
|
|
|
113 |
request.body: json - amount of correct and incorrect answers in the account
|
114 |
{
|
115 |
'number_correct': 0,
|
116 |
+
'number_incorrect': 0,
|
117 |
+
'level': 'easy'
|
118 |
}
|
119 |
|
120 |
Output
|
121 |
context: dict - the information for the current state
|
122 |
{
|
123 |
'text': 'What is 1+2?',
|
124 |
+
'question_numbers': [1,2,3], #2 or 3 numbers
|
125 |
'right_answer': 3,
|
126 |
'number_correct': 0,
|
127 |
'number_incorrect': 0,
|
|
|
132 |
message_data = ast.literal_eval(data_dict.get('message_data', '').get('message_body', ''))
|
133 |
number_correct = message_data['number_correct']
|
134 |
number_incorrect = message_data['number_incorrect']
|
135 |
+
level = message_data['level']
|
136 |
|
137 |
+
return JSONResponse(start_interactive_math(number_correct, number_incorrect, level))
|
138 |
|
139 |
|
140 |
@app.post("/hint")
|
|
|
144 |
Input
|
145 |
request.body: json - amount of correct and incorrect answers in the account
|
146 |
{
|
147 |
+
'question_numbers': [1,2,3], # 2 or 3 numbers
|
148 |
'right_answer': 3,
|
|
|
149 |
'number_correct': 0,
|
150 |
'number_incorrect': 0,
|
151 |
+
'level': 'easy',
|
152 |
'hints_used': 0
|
153 |
}
|
154 |
|
|
|
156 |
context: dict - the information for the current state
|
157 |
{
|
158 |
'text': 'What is 1+2?',
|
159 |
+
'question_numbers': [1,2,3], #2 or 3 numbers
|
160 |
'right_answer': 3,
|
161 |
'number_correct': 0,
|
162 |
'number_incorrect': 0,
|
163 |
+
'level': 'easy',
|
164 |
'hints_used': 0
|
165 |
}
|
166 |
"""
|
167 |
data_dict = await request.json()
|
168 |
message_data = ast.literal_eval(data_dict.get('message_data', '').get('message_body', ''))
|
169 |
+
question_numbers = message_data['question_numbers']
|
170 |
+
right_answer = message_data['right_answer']
|
171 |
number_correct = message_data['number_correct']
|
172 |
number_incorrect = message_data['number_incorrect']
|
173 |
+
level = message_data['level']
|
174 |
hints_used = message_data['hints_used']
|
175 |
|
176 |
+
return JSONResponse(generate_hint(question_numbers, right_answer, number_correct, number_incorrect, level, hints_used))
|