Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -58,15 +58,17 @@ with gr.Blocks() as demo:
|
|
58 |
|
59 |
def _retrieve(message, chat_history):
|
60 |
idx = int(message)
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
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:
|