sandz7 commited on
Commit
c6a3b9e
Β·
verified Β·
1 Parent(s): c8fdeaf

placed spaces.get and set for using the mode variable

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -126,7 +126,8 @@ def bot_comms(message, history):
126
  """
127
  Handles communication between Gradio and the models.
128
  """
129
- global mode
 
130
  logger.debug(f"bot_comms called with message: {message} and mode: {mode}")
131
 
132
  if message == "check cuda":
@@ -136,13 +137,13 @@ def bot_comms(message, history):
136
 
137
  if message == "imagery":
138
  logger.debug("Switching to imagery mode.")
139
- mode = message
140
  yield "Imagery On! Type your prompt to make the image πŸ–ΌοΈ"
141
  return
142
 
143
  if message == "chatting":
144
  logger.debug("Switching to chatting mode.")
145
- mode = message
146
  yield "Imagery Off. Ask me any questions. β˜„οΈ"
147
  return
148
 
 
126
  """
127
  Handles communication between Gradio and the models.
128
  """
129
+ # global mode
130
+ mode = spaces.get("mode", default="")
131
  logger.debug(f"bot_comms called with message: {message} and mode: {mode}")
132
 
133
  if message == "check cuda":
 
137
 
138
  if message == "imagery":
139
  logger.debug("Switching to imagery mode.")
140
+ spaces.set("mode", "imagery")
141
  yield "Imagery On! Type your prompt to make the image πŸ–ΌοΈ"
142
  return
143
 
144
  if message == "chatting":
145
  logger.debug("Switching to chatting mode.")
146
+ spaces.set("mode", "chatting")
147
  yield "Imagery Off. Ask me any questions. β˜„οΈ"
148
  return
149