Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,6 @@
|
|
1 |
import os
|
2 |
-
|
3 |
-
|
4 |
-
os.system('pip install gradio')
|
5 |
-
os.system('pip install minijinja')
|
6 |
-
os.system('pip install PyMuPDF')
|
7 |
-
|
8 |
import gradio as gr
|
9 |
from huggingface_hub import InferenceClient
|
10 |
from transformers import pipeline
|
@@ -47,7 +43,7 @@ def respond(message, history, system_message, max_tokens, temperature, top_p):
|
|
47 |
return response, history + [(message, response)]
|
48 |
|
49 |
def generate_case_outcome(prosecutor_response, defense_response):
|
50 |
-
prompt = f"Prosecutor's argument: {prosecutor_response}\nDefense Attorney's argument: {defense_response}\
|
51 |
evaluation = ""
|
52 |
for message in client.chat_completion(
|
53 |
[{"role": "system", "content": "Analyze the case and provide the outcome based on verified sources."},
|
@@ -105,19 +101,17 @@ def update_pdf_gallery_and_extract_text(pdf_files):
|
|
105 |
return pdf_files, pdf_text
|
106 |
|
107 |
def get_top_10_cases():
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
{
|
117 |
-
|
118 |
-
|
119 |
-
]
|
120 |
-
return "\n".join([f"{case['name']} - Case Number: {case['number']}" for case in cases])
|
121 |
|
122 |
def add_message(history, message):
|
123 |
for x in message["files"]:
|
|
|
1 |
import os
|
2 |
+
import requests
|
3 |
+
from bs4 import BeautifulSoup
|
|
|
|
|
|
|
|
|
4 |
import gradio as gr
|
5 |
from huggingface_hub import InferenceClient
|
6 |
from transformers import pipeline
|
|
|
43 |
return response, history + [(message, response)]
|
44 |
|
45 |
def generate_case_outcome(prosecutor_response, defense_response):
|
46 |
+
prompt = f"Prosecutor's argument: {prosecutor_response}\nDefense Attorney's argument: {defense_response}\nBased on verified sources, provide the case details and give the outcome along with reasons."
|
47 |
evaluation = ""
|
48 |
for message in client.chat_completion(
|
49 |
[{"role": "system", "content": "Analyze the case and provide the outcome based on verified sources."},
|
|
|
101 |
return pdf_files, pdf_text
|
102 |
|
103 |
def get_top_10_cases():
|
104 |
+
url = "https://www.courtlistener.com/?order_by=dateFiled+desc"
|
105 |
+
response = requests.get(url)
|
106 |
+
soup = BeautifulSoup(response.content, 'html.parser')
|
107 |
+
|
108 |
+
cases = []
|
109 |
+
for item in soup.select('.search-result', limit=10):
|
110 |
+
case_name = item.select_one('.search-result-title a').text.strip()
|
111 |
+
case_number = item.select_one('.search-result-meta').text.strip().split()[-1]
|
112 |
+
cases.append(f"{case_name} - Case Number: {case_number}")
|
113 |
+
|
114 |
+
return "\n".join(cases)
|
|
|
|
|
115 |
|
116 |
def add_message(history, message):
|
117 |
for x in message["files"]:
|