mirror of
https://github.com/StanGirard/quivr.git
synced 2024-11-30 21:28:56 +03:00
f952d7a269
* feat(v2): loaders added * feature: Add scroll animations * feature: upload ui * feature: upload multiple files * fix: Same file name and size remove * feat(crawler): added * feat(parsers): v2 added more * feat(v2): audio now working * feat(v2): all loaders * feat(v2): explorer * chore: add links * feat(api): added status in return message * refactor(website): remove old code * feat(upload): return type for messages * feature: redirect to upload if ENV=local * fix(chat): fixed some issues * feature: respect response type * loading state * feature: Loading stat * feat(v2): added explore and chat pages * feature: modal settings * style: Chat UI * feature: scroll to bottom when chatting * feature: smooth scroll in chat * feature(anim): Slide chat in * feature: markdown chat * feat(explorer): list * feat(doc): added document item * feat(explore): added modal * Add clarification on Project API keys and web interface for migration scripts to Readme (#58) * fix(demo): changed link * add support to uploading zip file (#62) * Catch UnicodeEncodeError exception (#64) * feature: fixed chatbar * fix(loaders): missing argument * fix: layout * fix: One whole chatbox * fix: Scroll into view * fix(build): vercel issues * chore(streamlit): moved to own file * refactor(api): moved to backend folder * feat(docker): added docker compose * Fix a bug where langchain memories were not being cleaned (#71) * Update README.md (#70) * chore(streamlit): moved to own file * refactor(api): moved to backend folder * docs(readme): updated for new version * docs(readme): added old readme * docs(readme): update copy dot env file * docs(readme): cleanup --------- Co-authored-by: iMADi-ARCH <nandanaditya985@gmail.com> Co-authored-by: Matt LeBel <github@lebel.io> Co-authored-by: Evan Carlson <45178375+EvanCarlson@users.noreply.github.com> Co-authored-by: Mustafa Hasan Khan <65130881+mustafahasankhan@users.noreply.github.com> Co-authored-by: zhulixi <48713110+zlxxlz1026@users.noreply.github.com> Co-authored-by: Stanisław Tuszyński <stanislaw@tuszynski.me>
40 lines
1.7 KiB
Python
40 lines
1.7 KiB
Python
import streamlit as st
|
|
import numpy as np
|
|
|
|
def brain(supabase):
|
|
## List all documents
|
|
response = supabase.table("documents").select("name:metadata->>file_name, size:metadata->>file_size", count="exact").execute()
|
|
|
|
documents = response.data # Access the data from the response
|
|
|
|
# Convert each dictionary to a tuple of items, then to a set to remove duplicates, and then back to a dictionary
|
|
unique_data = [dict(t) for t in set(tuple(d.items()) for d in documents)]
|
|
|
|
# Sort the list of documents by size in decreasing order
|
|
unique_data.sort(key=lambda x: int(x['size']), reverse=True)
|
|
|
|
# Display some metrics at the top of the page
|
|
col1, col2 = st.columns(2)
|
|
col1.metric(label="Total Documents", value=len(unique_data))
|
|
col2.metric(label="Total Size (bytes)", value=sum(int(doc['size']) for doc in unique_data))
|
|
|
|
for document in unique_data:
|
|
# Create a unique key for each button by using the document name
|
|
button_key = f"delete_{document['name']}"
|
|
|
|
# Display the document name, size and the delete button on the same line
|
|
col1, col2, col3 = st.columns([3, 1, 1])
|
|
col1.markdown(f"**{document['name']}** ({document['size']} bytes)")
|
|
|
|
if col2.button('❌', key=button_key):
|
|
delete_document(supabase, document['name'])
|
|
|
|
def delete_document(supabase, document_name):
|
|
# Delete the document from the database
|
|
response = supabase.table("documents").delete().match({"metadata->>file_name": document_name}).execute()
|
|
# Check if the deletion was successful
|
|
if len(response.data) > 0:
|
|
st.write(f"✂️ {document_name} was deleted.")
|
|
else:
|
|
st.write(f"❌ {document_name} was not deleted.")
|