AFischer1985 commited on
Commit
78c8391
·
1 Parent(s): 4f6f8bd

Update run.py

Browse files
Files changed (1) hide show
  1. run.py +11 -5
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
- bot_message = f"I was in state \"{previous_state}\" and am now in state \"{internal_state}\". please click another button."
34
- chat_history.append((state, bot_message))
35
- if(len(visible_elemIDs)==0):
36
- print("restore visibility to "+str(list(range(1,len(elemIDs)))))
37
- visible_elemIDs=defaultElemIDs # visibility of all buttons by default (i.e., without textbox)
 
 
 
 
 
 
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