mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-14 17:03:29 +03:00
feat(forget): now able to forget things
This commit is contained in:
parent
8f3d59e955
commit
7656450ddf
11
brain.py
11
brain.py
@ -1,12 +1,9 @@
|
||||
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()
|
||||
st.markdown(f"**Docs in DB:** {response.count}")
|
||||
|
||||
documents = response.data # Access the data from the response
|
||||
|
||||
@ -16,13 +13,18 @@ def brain(supabase):
|
||||
# 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.write(f"{document['name']} ({document['size']} bytes)")
|
||||
col1.markdown(f"**{document['name']}** ({document['size']} bytes)")
|
||||
|
||||
if col2.button('❌', key=button_key):
|
||||
delete_document(supabase, document['name'])
|
||||
@ -35,4 +37,3 @@ def delete_document(supabase, document_name):
|
||||
st.write(f"✂️ {document_name} was deleted.")
|
||||
else:
|
||||
st.write(f"❌ {document_name} was not deleted.")
|
||||
|
||||
|
12
main.py
12
main.py
@ -42,25 +42,29 @@ if 'chunk_overlap' not in st.session_state:
|
||||
st.session_state['chunk_overlap'] = 0
|
||||
|
||||
# Create a radio button for user to choose between adding knowledge or asking a question
|
||||
user_choice = st.radio("Choose an action", ('Add Knowledge to the Brain', 'Ask a Question to the Brain'))
|
||||
user_choice = st.radio("Choose an action", ('Add Knowledge', 'Chat with your Brain','Forget' ))
|
||||
|
||||
st.markdown("---\n\n")
|
||||
|
||||
brain(supabase)
|
||||
|
||||
if user_choice == 'Add Knowledge to the Brain':
|
||||
|
||||
if user_choice == 'Add Knowledge':
|
||||
# Display chunk size and overlap selection only when adding knowledge
|
||||
st.sidebar.title("Configuration")
|
||||
st.sidebar.markdown("Choose your chunk size and overlap for adding knowledge.")
|
||||
st.session_state['chunk_size'] = st.sidebar.slider("Select Chunk Size", 100, 1000, st.session_state['chunk_size'], 50)
|
||||
st.session_state['chunk_overlap'] = st.sidebar.slider("Select Chunk Overlap", 0, 100, st.session_state['chunk_overlap'], 10)
|
||||
file_uploader(supabase, openai_api_key, vector_store)
|
||||
elif user_choice == 'Ask a Question to the Brain':
|
||||
elif user_choice == 'Chat with your Brain':
|
||||
# Display model and temperature selection only when asking questions
|
||||
st.sidebar.title("Configuration")
|
||||
st.sidebar.markdown("Choose your model and temperature for asking questions.")
|
||||
st.session_state['model'] = st.sidebar.selectbox("Select Model", ["gpt-3.5-turbo", "gpt-4"], index=("gpt-3.5-turbo", "gpt-4").index(st.session_state['model']))
|
||||
st.session_state['temperature'] = st.sidebar.slider("Select Temperature", 0.0, 1.0, st.session_state['temperature'], 0.1)
|
||||
chat_with_doc(openai_api_key, vector_store)
|
||||
elif user_choice == 'Forget':
|
||||
st.sidebar.title("Configuration")
|
||||
|
||||
brain(supabase)
|
||||
|
||||
st.markdown("---\n\n")
|
Loading…
Reference in New Issue
Block a user