Hello,
I am trying to build an app with Streamlit for a RAG solution with Pinecone Assistant. One of the screen allows the user to view the files uploaded to Assistant and gives option to delete it.
I have a table that shows the details of the files and I’m trying to create a form in one of the table column that would have a hidden field and a button to delete the file.
I am not able to embed this form within the table column. It shows outside of the table.
Any ideas how this can be accomplished?
Below is the code that I have
html = '''<table class="center">
<thead>
<tr>
<th>File Name</th>
<th>File Status</th>
<th>File Size</th>
<th>Create On</th>
<th>Update On</th>
<th>File Id</th>
<th>Action</th>
</tr>
</thead>'''
st.title("Delete File")
## Get the list of files from Pinecone
filelist = assistant.list_files()
st.write(f"Below is the list of files in the database:")
## Look with the filelist and build the HTML table
for file in filelist:
html +=f'''
<tr>
<td>{file.name}</td>
<td>{file.status}</td>
<td>{file.size}</td>
<td>{file.created_on[0:19].replace('T',' ')}</td>
<td>{file.updated_on[0:19].replace('T',' ')}</td>
<td>{file.id}</td>
<td>
'''
form = st.form(key=f'{file.id}')
fileid = form.text_input(label=f'File Id: ', # {file.name}',
value=f'{file.id}',
disabled= True,
label_visibility= "visible")
submit = form.form_submit_button(label='', help='Delete this file',icon=":material/delete:")
html += f'{form}</td></tr>'
html += "</table>"
st.html(body=html)
if submit:
st.write(f'File deleted. File Id: {fileid}')
assistant.delete_file(file_id=fileid)