Spaces:
Build error
Build error
Commit
·
78c8391
1
Parent(s):
4f6f8bd
Update run.py
Browse files
run.py
CHANGED
|
@@ -30,11 +30,17 @@ def respond(state, chat_history, visible_elemIDs):
|
|
| 30 |
internal_state = state
|
| 31 |
visible_elemIDs= [e for e in visible_elemIDs
|
| 32 |
if ((str(e) != str(internal_state))|(str(e)=="1"))] # delete some buttons
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
print("respond:\n\nvisible_elemIDs="+str(visible_elemIDs)+"\n\nbot_message="+str(bot_message))
|
| 39 |
return state, chat_history, visible_elemIDs
|
| 40 |
|
|
|
|
| 30 |
internal_state = state
|
| 31 |
visible_elemIDs= [e for e in visible_elemIDs
|
| 32 |
if ((str(e) != str(internal_state))|(str(e)=="1"))] # delete some buttons
|
| 33 |
+
if(str(state) in [str(e) for e in visible_elemIDs]): # react to Buttons
|
| 34 |
+
bot_message = f"I was in state \"{previous_state}\" and am now in state \"{internal_state}\". please click another button."
|
| 35 |
+
chat_history.append((state, bot_message))
|
| 36 |
+
else: # react to Text-Input
|
| 37 |
+
internal_state=0
|
| 38 |
+
bot_message = f"I was in state \"{previous_state}\" and am now in state \"{internal_state}\" and ready to process \"{state}\". please click another button."
|
| 39 |
+
state=0
|
| 40 |
+
chat_history.append((state, bot_message))
|
| 41 |
+
if(len(visible_elemIDs)==0): # if visible_elemIDs has zero length, reset
|
| 42 |
+
print("restore visibility to "+str(defaultElemIDs))
|
| 43 |
+
visible_elemIDs=defaultElemIDs
|
| 44 |
print("respond:\n\nvisible_elemIDs="+str(visible_elemIDs)+"\n\nbot_message="+str(bot_message))
|
| 45 |
return state, chat_history, visible_elemIDs
|
| 46 |
|