Spaces:
Running
Running
fix self-query retriever
Browse files
app.py
CHANGED
@@ -35,8 +35,6 @@ st.set_page_config(page_title="ChatData")
|
|
35 |
|
36 |
st.header("ChatData")
|
37 |
|
38 |
-
columns = ['ref_id', 'title', 'id', 'categories', 'abstract', 'authors', 'pubdate']
|
39 |
-
|
40 |
|
41 |
def try_eval(x):
|
42 |
try:
|
@@ -45,12 +43,12 @@ def try_eval(x):
|
|
45 |
return x
|
46 |
|
47 |
|
48 |
-
def display(dataframe,
|
49 |
if index:
|
50 |
dataframe.set_index(index)
|
51 |
if len(dataframe) > 0:
|
52 |
-
if
|
53 |
-
st.dataframe(dataframe[
|
54 |
else:
|
55 |
st.dataframe(dataframe)
|
56 |
else:
|
@@ -261,7 +259,7 @@ ENGINE = ReplacingMergeTree ORDER BY id
|
|
261 |
f"### Answer from LLM\n{ret['answer']}\n### References")
|
262 |
docs = ret['sources']
|
263 |
docs = pd.DataFrame([{**d.metadata, 'abstract': d.page_content} for d in docs])
|
264 |
-
display(docs,
|
265 |
except Exception as e:
|
266 |
st.write('Oops π΅ Something bad happened...')
|
267 |
raise e
|
@@ -288,7 +286,7 @@ with tab_self_query:
|
|
288 |
docs = pd.DataFrame(
|
289 |
[{**d.metadata, 'abstract': d.page_content} for d in docs])
|
290 |
|
291 |
-
display(docs,
|
292 |
except Exception as e:
|
293 |
st.write('Oops π΅ Something bad happened...')
|
294 |
raise e
|
@@ -307,7 +305,7 @@ with tab_self_query:
|
|
307 |
f"### Answer from LLM\n{ret['answer']}\n### References")
|
308 |
docs = ret['sources']
|
309 |
docs = pd.DataFrame([{**d.metadata, 'abstract': d.page_content} for d in docs])
|
310 |
-
display(docs,
|
311 |
except Exception as e:
|
312 |
st.write('Oops π΅ Something bad happened...')
|
313 |
raise e
|
|
|
35 |
|
36 |
st.header("ChatData")
|
37 |
|
|
|
|
|
38 |
|
39 |
def try_eval(x):
|
40 |
try:
|
|
|
43 |
return x
|
44 |
|
45 |
|
46 |
+
def display(dataframe, columns_=None, index=None):
|
47 |
if index:
|
48 |
dataframe.set_index(index)
|
49 |
if len(dataframe) > 0:
|
50 |
+
if columns_:
|
51 |
+
st.dataframe(dataframe[columns_])
|
52 |
else:
|
53 |
st.dataframe(dataframe)
|
54 |
else:
|
|
|
259 |
f"### Answer from LLM\n{ret['answer']}\n### References")
|
260 |
docs = ret['sources']
|
261 |
docs = pd.DataFrame([{**d.metadata, 'abstract': d.page_content} for d in docs])
|
262 |
+
display(docs, ['ref_id', 'title', 'id', 'categories', 'abstract', 'authors', 'pubdate'], index='ref_id')
|
263 |
except Exception as e:
|
264 |
st.write('Oops π΅ Something bad happened...')
|
265 |
raise e
|
|
|
286 |
docs = pd.DataFrame(
|
287 |
[{**d.metadata, 'abstract': d.page_content} for d in docs])
|
288 |
|
289 |
+
display(docs, ['title', 'id', 'categories', 'abstract', 'authors', 'pubdate'])
|
290 |
except Exception as e:
|
291 |
st.write('Oops π΅ Something bad happened...')
|
292 |
raise e
|
|
|
305 |
f"### Answer from LLM\n{ret['answer']}\n### References")
|
306 |
docs = ret['sources']
|
307 |
docs = pd.DataFrame([{**d.metadata, 'abstract': d.page_content} for d in docs])
|
308 |
+
display(docs, ['title', 'id', 'categories', 'abstract', 'authors', 'pubdate'], index='ref_id')
|
309 |
except Exception as e:
|
310 |
st.write('Oops π΅ Something bad happened...')
|
311 |
raise e
|