Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -221,6 +221,22 @@ def update_pdf_gallery_and_extract_text(pdf_files):
|
|
221 |
pdf_text = ""
|
222 |
return pdf_files, pdf_text
|
223 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
224 |
def add_message(history, message):
|
225 |
for x in message["files"]:
|
226 |
history.append(((x,), None))
|
@@ -265,34 +281,41 @@ with gr.Blocks(css=custom_css) as demo:
|
|
265 |
shared_history = gr.State([])
|
266 |
pdf_files = gr.State([])
|
267 |
pdf_text = gr.State("")
|
268 |
-
|
|
|
269 |
with gr.Tab("Argument Evaluation"):
|
270 |
-
message = gr.Textbox(label="Case to Argue")
|
271 |
-
system_message1 = gr.State("You are an expert Prosecutor. Give your best arguments for the case on behalf of the prosecution.")
|
272 |
-
system_message2 = gr.State("You are an expert Defense Attorney. Give your best arguments for the case on behalf of the Defense.")
|
273 |
-
max_tokens = gr.State(512)
|
274 |
-
temperature = gr.State(0.6)
|
275 |
-
top_p = gr.State(0.95)
|
276 |
-
|
277 |
with gr.Row():
|
278 |
-
with gr.Column(scale=4):
|
279 |
-
prosecutor_response = gr.Textbox(label="Prosecutor's Response", interactive=True, elem_classes=["scroll-box"])
|
280 |
-
with gr.Column(scale=1):
|
281 |
-
prosecutor_score_color = gr.HTML()
|
282 |
-
|
283 |
-
with gr.Column(scale=4):
|
284 |
-
defense_response = gr.Textbox(label="Defense Attorney's Response", interactive=True, elem_classes=["scroll-box"])
|
285 |
with gr.Column(scale=1):
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
296 |
|
297 |
with gr.Tab("PDF Management"):
|
298 |
pdf_upload = gr.File(label="Upload Case Files (PDF)", file_types=[".pdf"])
|
|
|
221 |
pdf_text = ""
|
222 |
return pdf_files, pdf_text
|
223 |
|
224 |
+
def get_top_10_cases():
|
225 |
+
prompt = "Give me a list of the current top 10 cases in the country being discussed by the top lawyers in the country."
|
226 |
+
response = ""
|
227 |
+
for message in client.chat_completion(
|
228 |
+
[{"role": "system", "content": "You are a legal expert providing information about top legal cases."},
|
229 |
+
{"role": "user", "content": prompt}],
|
230 |
+
max_tokens=512,
|
231 |
+
stream=True,
|
232 |
+
temperature=0.6,
|
233 |
+
top_p=0.95,
|
234 |
+
):
|
235 |
+
token = message.choices[0].delta.content
|
236 |
+
if token is not None:
|
237 |
+
response += token
|
238 |
+
return response
|
239 |
+
|
240 |
def add_message(history, message):
|
241 |
for x in message["files"]:
|
242 |
history.append(((x,), None))
|
|
|
281 |
shared_history = gr.State([])
|
282 |
pdf_files = gr.State([])
|
283 |
pdf_text = gr.State("")
|
284 |
+
top_10_cases = gr.State("")
|
285 |
+
|
286 |
with gr.Tab("Argument Evaluation"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
with gr.Row():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
288 |
with gr.Column(scale=1):
|
289 |
+
top_10_btn = gr.Button("Give me the top 10 cases")
|
290 |
+
top_10_output = gr.Textbox(label="Top 10 Cases", interactive=False, elem_classes=["scroll-box"])
|
291 |
+
top_10_btn.click(get_top_10_cases, outputs=top_10_output)
|
292 |
+
with gr.Column(scale=2):
|
293 |
+
message = gr.Textbox(label="Case to Argue")
|
294 |
+
system_message1 = gr.State("You are an expert Prosecutor. Give your best arguments for the case on behalf of the prosecution.")
|
295 |
+
system_message2 = gr.State("You are an expert Defense Attorney. Give your best arguments for the case on behalf of the Defense.")
|
296 |
+
max_tokens = gr.State(512)
|
297 |
+
temperature = gr.State(0.6)
|
298 |
+
top_p = gr.State(0.95)
|
299 |
+
|
300 |
+
with gr.Row():
|
301 |
+
with gr.Column(scale=4):
|
302 |
+
prosecutor_response = gr.Textbox(label="Prosecutor's Response", interactive=True, elem_classes=["scroll-box"])
|
303 |
+
with gr.Column(scale=1):
|
304 |
+
prosecutor_score_color = gr.HTML()
|
305 |
+
|
306 |
+
with gr.Column(scale=4):
|
307 |
+
defense_response = gr.Textbox(label="Defense Attorney's Response", interactive=True, elem_classes=["scroll-box"])
|
308 |
+
with gr.Column(scale=1):
|
309 |
+
defense_score_color = gr.HTML()
|
310 |
+
|
311 |
+
shared_argument = gr.Textbox(label="Case Outcome", interactive=True)
|
312 |
+
submit_btn = gr.Button("Argue")
|
313 |
+
clear_btn = gr.Button("Clear and Reset")
|
314 |
+
save_btn = gr.Button("Save Conversation")
|
315 |
+
|
316 |
+
submit_btn.click(chat_between_bots, inputs=[system_message1, system_message2, max_tokens, temperature, top_p, history1, history2, shared_history, message], outputs=[prosecutor_response, defense_response, history1, history2, shared_argument, prosecutor_score_color, defense_score_color])
|
317 |
+
clear_btn.click(reset_conversation, outputs=[history1, history2, shared_history, prosecutor_response, defense_response, shared_argument])
|
318 |
+
save_btn.click(save_conversation, inputs=[history1, history2, shared_history], outputs=[history1, history2, shared_history])
|
319 |
|
320 |
with gr.Tab("PDF Management"):
|
321 |
pdf_upload = gr.File(label="Upload Case Files (PDF)", file_types=[".pdf"])
|