Spaces:
Runtime error
Runtime error
Greg Thompson
commited on
Commit
·
b1bc7e0
1
Parent(s):
b71b7ec
Update conditions for managing the exit state
Browse files
mathtext_fastapi/conversation_manager.py
CHANGED
@@ -123,7 +123,8 @@ def return_next_conversational_state(context_data, user_message, contact_uuid):
|
|
123 |
'input_prompt': "Welcome to our math practice. What would you like to try? Type add or subtract.",
|
124 |
'state': "welcome-sequence"
|
125 |
}
|
126 |
-
elif
|
|
|
127 |
|
128 |
fsm_check = SUPA.table('state_machines').select("*").eq(
|
129 |
"contact_uuid",
|
@@ -153,10 +154,15 @@ def return_next_conversational_state(context_data, user_message, contact_uuid):
|
|
153 |
"contact_uuid", contact_uuid
|
154 |
).execute()
|
155 |
|
|
|
|
|
|
|
|
|
|
|
156 |
message_package = {
|
157 |
'messages': messages,
|
158 |
'input_prompt': "temporary value",
|
159 |
-
'state':
|
160 |
}
|
161 |
elif user_message == 'subtract':
|
162 |
message_package = {
|
@@ -167,7 +173,7 @@ def return_next_conversational_state(context_data, user_message, contact_uuid):
|
|
167 |
'input_prompt': "Here's the first one... What's 3-1?",
|
168 |
'state': "subtract-question-sequence"
|
169 |
}
|
170 |
-
elif user_message == 'exit':
|
171 |
message_package = {
|
172 |
'messages': [
|
173 |
"Great, thanks for practicing math today. Come back any time."
|
|
|
123 |
'input_prompt': "Welcome to our math practice. What would you like to try? Type add or subtract.",
|
124 |
'state': "welcome-sequence"
|
125 |
}
|
126 |
+
elif context_data['state'] == 'addition-question-sequence' or \
|
127 |
+
user_message == 'add':
|
128 |
|
129 |
fsm_check = SUPA.table('state_machines').select("*").eq(
|
130 |
"contact_uuid",
|
|
|
154 |
"contact_uuid", contact_uuid
|
155 |
).execute()
|
156 |
|
157 |
+
if user_message == 'exit':
|
158 |
+
state_label = 'exit'
|
159 |
+
else:
|
160 |
+
state_label = 'addition-question-sequence'
|
161 |
+
|
162 |
message_package = {
|
163 |
'messages': messages,
|
164 |
'input_prompt': "temporary value",
|
165 |
+
'state': state_label
|
166 |
}
|
167 |
elif user_message == 'subtract':
|
168 |
message_package = {
|
|
|
173 |
'input_prompt': "Here's the first one... What's 3-1?",
|
174 |
'state': "subtract-question-sequence"
|
175 |
}
|
176 |
+
elif context_data['state'] == 'exit' or user_message == 'exit':
|
177 |
message_package = {
|
178 |
'messages': [
|
179 |
"Great, thanks for practicing math today. Come back any time."
|