kaxap commited on
Commit
2466cd5
1 Parent(s): 81d489e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -59,10 +59,15 @@ with gr.Blocks() as demo:
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
  chat_history.append((message, f"contents of {n}:\n{df[df_idx]}"))
67
  return "", chat_history
68
 
@@ -72,7 +77,7 @@ with gr.Blocks() as demo:
72
  int(message)
73
  print(f"retrieving #{message}")
74
  return _retrieve(message, chat_history)
75
- except:
76
  print(traceback.format_exc())
77
  print(f"searching for {message}")
78
  return _search(message, chat_history)
 
59
  def _retrieve(message, chat_history):
60
  idx = int(message)
61
  for _, m in chat_history[::-1]:
62
+ print("chat message: ", m)
63
  if m.startswith("results:\n"):
64
+ print("found results")
65
  for n in m.split("\n")[1:]:
66
+ print("result item: ", n)
67
  if str(idx) == n.split(".")[0]:
68
+ print("found the number")
69
  df_idx = int(n.split(" // ")[-1])
70
+ print("df_idx", df_idx)
71
  chat_history.append((message, f"contents of {n}:\n{df[df_idx]}"))
72
  return "", chat_history
73
 
 
77
  int(message)
78
  print(f"retrieving #{message}")
79
  return _retrieve(message, chat_history)
80
+ except ValueError:
81
  print(traceback.format_exc())
82
  print(f"searching for {message}")
83
  return _search(message, chat_history)