kaxap commited on
Commit
502c63e
1 Parent(s): 2d61b6b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -9
app.py CHANGED
@@ -58,15 +58,17 @@ with gr.Blocks() as demo:
58
 
59
  def _retrieve(message, chat_history):
60
  idx = int(message)
61
- for _, m in chat_history[::-1]:
62
- if m.startswith("results:\n"):
63
- for n in m.split("\n")[1:]:
64
- if str(idx) == n.split(".")[0]:
65
- df_idx = int(n.split(" // ")[-1])
66
- article = df.iloc[df_idx]['text'].replace("==", "\n\n==")
67
- chat_history.append((message, f"contents of {n}:\n{article}"))
68
- return "", chat_history
69
-
 
 
70
  def respond(message, chat_history):
71
  print(f"received input '{message}'")
72
  try:
 
58
 
59
  def _retrieve(message, chat_history):
60
  idx = int(message)
61
+ try:
62
+ for _, m in chat_history[::-1]:
63
+ if m.startswith("results:\n"):
64
+ for n in m.split("\n")[1:]:
65
+ if str(idx) == n.split(".")[0]:
66
+ df_idx = int(n.split(" // ")[-1])
67
+ article = df.iloc[df_idx]['text'].replace("==", "\n\n==")
68
+ chat_history.append((message, f"contents of {n}:\n{article}"))
69
+ return "", chat_history
70
+ except:
71
+ print(traceback.format_exc())
72
  def respond(message, chat_history):
73
  print(f"received input '{message}'")
74
  try: