kaxap commited on
Commit
c0e5a43
1 Parent(s): 9358826

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -11
app.py CHANGED
@@ -58,17 +58,19 @@ with gr.Blocks() as demo:
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:
 
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
+ print(n)
65
+ if str(idx) == n.split(".")[0]:
66
+ df_idx = int(n.split(" // ")[-1])
67
+ print(df_idx)
68
+ article = df.iloc[df_idx]['text'].replace("==", "\n\n==")
69
+ chat_history.append((message, f"contents of {n}:\n{article}"))
70
+ return "", chat_history
71
+ print("nothing found")
72
+ return chat_history.append((message, "article not found"))
73
+
74
  def respond(message, chat_history):
75
  print(f"received input '{message}'")
76
  try: