Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,12 +3,6 @@ import requests
|
|
3 |
import os
|
4 |
from openai import OpenAI
|
5 |
|
6 |
-
headers = {
|
7 |
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.19582"
|
8 |
-
}
|
9 |
-
|
10 |
-
proxies = {"http": os.getenv("HTTP_PROXY")}
|
11 |
-
|
12 |
@st.cache_data(ttl=3600)
|
13 |
def extract_text_from_api(query):
|
14 |
url = "https://fastapi-example-uqyy.onrender.com/extract_text"
|
@@ -21,7 +15,7 @@ def extract_text_from_api(query):
|
|
21 |
"num_results": 1
|
22 |
}
|
23 |
|
24 |
-
response = requests.get(url,
|
25 |
|
26 |
if response.status_code == 200:
|
27 |
return response.json().get("text", "")
|
@@ -37,6 +31,7 @@ def get_summary(text):
|
|
37 |
messages=[
|
38 |
{"role": "system", "content": '''You are a law professor specialized in legal writing and legal research.
|
39 |
When presented with a case by a user please summarize it according to the following requirements:
|
|
|
40 |
Name of the court.
|
41 |
Facts (name of the parties, what happened factually).
|
42 |
Procedural history (what happened in the past procedurally, what were prior judgements).
|
@@ -45,8 +40,9 @@ def get_summary(text):
|
|
45 |
Rationale (reasons for the holding).
|
46 |
Decision (what did the court decide, e.g. affirmed, overruled).
|
47 |
Other opinions (if there are any dissenting or concurring opinions, summarize majority opinion, dissenting opinion and concurring opinion).
|
48 |
-
Cases cited (which cases the court cited and how it treated them).
|
49 |
-
|
|
|
50 |
]
|
51 |
)
|
52 |
|
@@ -55,14 +51,14 @@ def get_summary(text):
|
|
55 |
|
56 |
st.write("\n")
|
57 |
st.write("\n")
|
58 |
-
search_query = st.text_input("
|
59 |
|
60 |
if search_query:
|
61 |
-
|
62 |
-
|
63 |
if text:
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
else:
|
68 |
st.write("Failed to extract text from the external API.")
|
|
|
3 |
import os
|
4 |
from openai import OpenAI
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
@st.cache_data(ttl=3600)
|
7 |
def extract_text_from_api(query):
|
8 |
url = "https://fastapi-example-uqyy.onrender.com/extract_text"
|
|
|
15 |
"num_results": 1
|
16 |
}
|
17 |
|
18 |
+
response = requests.get(url, params=params)
|
19 |
|
20 |
if response.status_code == 200:
|
21 |
return response.json().get("text", "")
|
|
|
31 |
messages=[
|
32 |
{"role": "system", "content": '''You are a law professor specialized in legal writing and legal research.
|
33 |
When presented with a case by a user please summarize it according to the following requirements:
|
34 |
+
Name and citation of the case.
|
35 |
Name of the court.
|
36 |
Facts (name of the parties, what happened factually).
|
37 |
Procedural history (what happened in the past procedurally, what were prior judgements).
|
|
|
40 |
Rationale (reasons for the holding).
|
41 |
Decision (what did the court decide, e.g. affirmed, overruled).
|
42 |
Other opinions (if there are any dissenting or concurring opinions, summarize majority opinion, dissenting opinion and concurring opinion).
|
43 |
+
Cases cited (which cases the court cited and how it treated them).
|
44 |
+
Present in markdown format'''},
|
45 |
+
{"role": "user", "content": f"Please summarize this case: {text}. "}
|
46 |
]
|
47 |
)
|
48 |
|
|
|
51 |
|
52 |
st.write("\n")
|
53 |
st.write("\n")
|
54 |
+
search_query = st.text_input("case name, e.g. brown v board supreme, 372 US 335, google v oracle appeal")
|
55 |
|
56 |
if search_query:
|
57 |
+
|
58 |
+
text = extract_text_from_api(search_query)
|
59 |
if text:
|
60 |
+
|
61 |
+
summary = get_summary(text)
|
62 |
+
st.write(summary)
|
63 |
else:
|
64 |
st.write("Failed to extract text from the external API.")
|