Spaces:
Running
Running
marcellopoliti
commited on
Commit
β’
aadb9c7
1
Parent(s):
1f71023
feat: error handling
Browse files- app.py +1 -2
- pages/manage_knowledge_box.py +23 -33
- retrieve_kb.py +5 -2
app.py
CHANGED
@@ -98,8 +98,7 @@ show_sidebar()
|
|
98 |
|
99 |
|
100 |
col1, col2, col3 = st.columns((1, 4, 1))
|
101 |
-
|
102 |
-
st.image("https://brianknows.org/brian_logo.png", width=300)
|
103 |
st.write("# Brian Knowledge Base System! π")
|
104 |
|
105 |
|
|
|
98 |
|
99 |
|
100 |
col1, col2, col3 = st.columns((1, 4, 1))
|
101 |
+
|
|
|
102 |
st.write("# Brian Knowledge Base System! π")
|
103 |
|
104 |
|
pages/manage_knowledge_box.py
CHANGED
@@ -187,7 +187,7 @@ else:
|
|
187 |
st.warning(f"{collection_name} KB is empty")
|
188 |
|
189 |
|
190 |
-
tab1, tab2, tab3, tab4, tab5, tab6 = st.tabs(
|
191 |
[
|
192 |
"Remove",
|
193 |
"Add URL",
|
@@ -195,20 +195,10 @@ tab1, tab2, tab3, tab4, tab5, tab6 = st.tabs(
|
|
195 |
"Add PDF",
|
196 |
"Add Youtube",
|
197 |
"Notion and Jina",
|
|
|
198 |
]
|
199 |
)
|
200 |
|
201 |
-
# tab1, tab2, tab3, tab4, tab5, tab6, tab7 = st.tabs(
|
202 |
-
# [
|
203 |
-
# "Remove",
|
204 |
-
# "Add URL",
|
205 |
-
# "Multiple URL",
|
206 |
-
# "Add PDF",
|
207 |
-
# "Add Youtube",
|
208 |
-
# "Notion and Jina",
|
209 |
-
# "Rename",
|
210 |
-
# ]
|
211 |
-
# )
|
212 |
# remove stuff tab
|
213 |
with tab1:
|
214 |
# remove a split
|
@@ -351,24 +341,24 @@ with tab6:
|
|
351 |
except Exception as e:
|
352 |
st.error(f"{str(e)}")
|
353 |
|
354 |
-
|
355 |
-
|
356 |
-
#
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
|
|
187 |
st.warning(f"{collection_name} KB is empty")
|
188 |
|
189 |
|
190 |
+
tab1, tab2, tab3, tab4, tab5, tab6, tab7 = st.tabs(
|
191 |
[
|
192 |
"Remove",
|
193 |
"Add URL",
|
|
|
195 |
"Add PDF",
|
196 |
"Add Youtube",
|
197 |
"Notion and Jina",
|
198 |
+
"Rename",
|
199 |
]
|
200 |
)
|
201 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
# remove stuff tab
|
203 |
with tab1:
|
204 |
# remove a split
|
|
|
341 |
except Exception as e:
|
342 |
st.error(f"{str(e)}")
|
343 |
|
344 |
+
with tab7:
|
345 |
+
|
346 |
+
# remove a split
|
347 |
+
st.header("Rename collection")
|
348 |
+
new_name = st.text_input("New collection name")
|
349 |
+
collection_info, coll, client = get_knowledge_base_information(
|
350 |
+
client=client,
|
351 |
+
embedding_function=default_embedding_function,
|
352 |
+
kb_name=collection_name,
|
353 |
+
)
|
354 |
+
|
355 |
+
if st.button("rename"):
|
356 |
+
try:
|
357 |
+
coll.modify(
|
358 |
+
name=new_name,
|
359 |
+
)
|
360 |
+
except Exception as e:
|
361 |
+
st.error(f"{str(e)}")
|
362 |
+
st.success("Done")
|
363 |
+
time.sleep(1)
|
364 |
+
st.experimental_rerun()
|
retrieve_kb.py
CHANGED
@@ -10,8 +10,11 @@ default_embedding_function = get_embedding_function(openai_key=openai_key)
|
|
10 |
|
11 |
|
12 |
def get_current_knowledge_bases(client):
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
15 |
|
16 |
|
17 |
def get_knowledge_base_information(
|
|
|
10 |
|
11 |
|
12 |
def get_current_knowledge_bases(client):
|
13 |
+
try:
|
14 |
+
knowledge_boxes = client.list_collections()
|
15 |
+
return knowledge_boxes
|
16 |
+
except:
|
17 |
+
raise Exception("Error retreiving kbs")
|
18 |
|
19 |
|
20 |
def get_knowledge_base_information(
|