Spaces:
Build error
Build error
Update components/sidebar.py
Browse files- components/sidebar.py +32 -37
components/sidebar.py
CHANGED
|
@@ -1,41 +1,36 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from typing import Dict, Optional
|
| 3 |
|
| 4 |
-
def render_sidebar(case_manager) -> Optional[str]:
|
| 5 |
-
"""Render sidebar with case management"""
|
| 6 |
-
with st.sidebar:
|
| 7 |
-
st.title("Legal AI Assistant")
|
| 8 |
-
|
| 9 |
-
# Case creation
|
| 10 |
-
with st.expander("Create New Case"):
|
| 11 |
-
with st.form("new_case"):
|
| 12 |
-
title = st.text_input("Case Title")
|
| 13 |
-
description = st.text_area("Description")
|
| 14 |
-
case_type = st.selectbox(
|
| 15 |
-
"Case Type",
|
| 16 |
-
["Contract", "Employment", "Intellectual Property", "Litigation"]
|
| 17 |
-
)
|
| 18 |
-
|
| 19 |
-
if st.form_submit_button("Create Case"):
|
| 20 |
-
if title:
|
| 21 |
-
case_id = case_manager.create_case(title, description, case_type)
|
| 22 |
-
st.success("Case created successfully!")
|
| 23 |
-
return case_id
|
| 24 |
-
else:
|
| 25 |
-
st.error("Please enter a case title")
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from typing import Dict, Optional
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
def render_sidebar(uploaded_docs):
|
| 6 |
+
"""Render the sidebar with uploaded document list."""
|
| 7 |
+
st.sidebar.title("Legal AI Assistant")
|
| 8 |
+
|
| 9 |
+
# Upload documents section
|
| 10 |
+
with st.sidebar.expander("Upload Documents", expanded=True):
|
| 11 |
+
uploaded_files = st.file_uploader(
|
| 12 |
+
"Choose files",
|
| 13 |
+
accept_multiple_files=True,
|
| 14 |
+
type=["pdf", "docx", "txt"]
|
| 15 |
+
)
|
| 16 |
+
if uploaded_files:
|
| 17 |
+
for uploaded_file in uploaded_files:
|
| 18 |
+
if 'uploaded_docs' not in st.session_state:
|
| 19 |
+
st.session_state.uploaded_docs = []
|
| 20 |
+
st.session_state.uploaded_docs.append({
|
| 21 |
+
'name': uploaded_file.name,
|
| 22 |
+
'data': uploaded_file.read(),
|
| 23 |
+
'processed': False
|
| 24 |
+
})
|
| 25 |
+
st.success(f"{len(uploaded_files)} documents uploaded.")
|
| 26 |
+
|
| 27 |
+
# List uploaded documents
|
| 28 |
+
st.sidebar.subheader("Uploaded Documents")
|
| 29 |
+
if uploaded_docs:
|
| 30 |
+
for doc in uploaded_docs:
|
| 31 |
+
status = "✅ Processed" if doc.get("processed", False) else "⏳ Pending"
|
| 32 |
+
st.sidebar.markdown(f"- {doc['name']} ({status})")
|
| 33 |
+
else:
|
| 34 |
+
st.sidebar.info("No documents uploaded yet.")
|
| 35 |
+
|
| 36 |
+
|