-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
74 lines (59 loc) · 2.87 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import streamlit as st
import requests
# Streamlit UI Enhancements
# Set page config (optional, for title and icon in the browser tab)
st.set_page_config(page_title="Law Navigator System", page_icon="⚖️")
# Sidebar for branding or navigation
st.sidebar.title("Law Navigator System")
st.sidebar.markdown("Your AI-powered legal research engine")
# Header and welcome section
st.title("⚖️ Law Navigator System")
st.markdown("#### *Your go-to AI-powered legal assistant!*")
st.write(
"Upload your legal documents and ask any legal query. "
"Our AI will assist you with legal advice, generate reports, or predict case outcomes."
)
# File uploader (multiple files)
st.markdown("### Upload your legal documents:")
uploaded_files = st.file_uploader("Upload PDF files", type=["pdf"], accept_multiple_files=True)
# Text input for user query
st.markdown("### Enter your legal query:")
query = st.text_area("Describe your legal issue or ask a question:")
# Dropdown for task selection
st.markdown("### What would you like assistance with?")
option = st.selectbox(
"Select a task:",
["Legal Advisory", "Legal Report Generation", "Case Outcome Prediction"]
)
# Button to submit the query and files
if st.button("Submit"):
if not uploaded_files or not query or not option:
st.error("Please upload files, enter a query, and select an option.")
else:
# Create multipart form-data request payload
files = [("files", (file.name, file, file.type)) for file in uploaded_files]
data = {
"query": query,
"option": option
}
# Call the API (replace the URL with your API endpoint)
api_url = "https://navilaw-ai.onrender.com/legal-assistance/"
response = requests.post(api_url, files=files, data=data)
# Check response and display result
if response.status_code == 200:
result = response.json()
st.success("Response received successfully!")
if "result" in result:
st.markdown(f"### ⚖️ Legal Advice:\n{result['result']}")
elif "report" in result:
st.markdown(f"### 📄 Legal Report:\n{result['report']}")
elif "prediction" in result:
st.markdown(f"### 🔮 Case Outcome Prediction:\n{result['prediction']}")
else:
st.error(f"Error: {response.status_code}, {response.text}")
# Footer with branding and links
st.markdown("---")
st.markdown("##### Powered by [Law Navigator AI](https://law-navigator.example.com)")
st.markdown("🔗 Connect with us: [LinkedIn](https://www.linkedin.com/in/devroop-saha-datafreak/) | [GitHub](https://github.com/devroopsaha744/navilaw-ai)")
st.sidebar.markdown("---")
st.sidebar.info("Having trouble? Contact us at [devroopsaha844@gmail.com](mailto:devroopsaha844@gmail.com)")