botsi commited on
Commit
62274e4
·
verified ·
1 Parent(s): e0db960

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -7
app.py CHANGED
@@ -67,18 +67,23 @@ with gr.Blocks(js=js) as demo:
67
  def user(user_message, url_params, history):
68
  return "", history + [[user_message, None]]
69
 
70
- def bot(history, url_params):
71
- if "hi" in history[-1][0]:
 
 
 
72
  session_index = url_params.get('session_index')
73
  if session_index: # Check if session_index is not None or empty
74
- bot_message = f"""{session_index}"""
 
 
 
75
  else:
76
- bot_message = "Session index is missing."
77
  else:
78
- bot_message = "There was an error. Please try again."
79
- history[-1][1] = bot_message
80
  time.sleep(1)
81
- return history
82
 
83
  msg.submit(user, inputs=[msg, url_params, chatbot], outputs=[msg, chatbot], queue=False).then(
84
  fn=bot, inputs=[chatbot, url_params], outputs=[chatbot]
 
67
  def user(user_message, url_params, history):
68
  return "", history + [[user_message, None]]
69
 
70
+ def get_session_index(url_params):
71
+ if url_params:
72
+ print(f"""
73
+ {json.dumps(url_params)}
74
+ """)
75
  session_index = url_params.get('session_index')
76
  if session_index: # Check if session_index is not None or empty
77
+ print(session_index)
78
+ # Fetch personalized data
79
+ personalized_data = fetch_personalized_data(session_index)
80
+ print(personalized_data)
81
  else:
82
+ print("Session index is missing.")
83
  else:
84
+ print("There are no URL parameters available.")
 
85
  time.sleep(1)
86
+ return session_index
87
 
88
  msg.submit(user, inputs=[msg, url_params, chatbot], outputs=[msg, chatbot], queue=False).then(
89
  fn=bot, inputs=[chatbot, url_params], outputs=[chatbot]