michaelmc1618 commited on
Commit
c705ca2
·
verified ·
1 Parent(s): 29c2179

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -11,7 +11,7 @@ from transformers import pipeline
11
  from datasets import load_dataset
12
  import fitz # PyMuPDF
13
 
14
- # Loading datasets
15
  dataset = load_dataset("ibunescu/qa_legal_dataset_train")
16
 
17
  # Different pipelines for different tasks
@@ -82,7 +82,7 @@ def determine_winner(outcome):
82
  else:
83
  return "No clear winner"
84
 
85
- # Custom CSS for white background and black text for input and output boxes
86
  custom_css = """
87
  body {
88
  background-color: #ffffff;
@@ -194,8 +194,8 @@ def update_pdf_gallery_and_extract_text(pdf_files):
194
  return pdf_files, pdf_text
195
 
196
  def get_top_10_cases():
197
- result = mask_filling_pipeline("Show 5 legal case with names and numbers from any State Court of Appeals in the US.", max_length=450, min_length=50, do_sample=False)
198
- return result[0]['text']
199
 
200
  def add_message(history, message):
201
  for x in message["files"]:
@@ -215,7 +215,7 @@ def bot(history):
215
  response = ""
216
  for message in client.chat_completion(
217
  messages,
218
- max_tokens=450,
219
  stream=True,
220
  temperature=0.6,
221
  top_p=0.95,
@@ -250,8 +250,8 @@ with gr.Blocks(css=custom_css) as demo:
250
  with gr.Tab("Argument Evaluation"):
251
  with gr.Row():
252
  with gr.Column(scale=1):
253
- top_10_btn = gr.Button("Give me 5 cases")
254
- top_10_output = gr.Textbox(label="Show 5 Cases", interactive=False, elem_classes=["scroll-box"])
255
  top_10_btn.click(get_top_10_cases, outputs=top_10_output)
256
  with gr.Column(scale=2):
257
  message = gr.Textbox(label="Case to Argue")
 
11
  from datasets import load_dataset
12
  import fitz # PyMuPDF
13
 
14
+ # Load dataset
15
  dataset = load_dataset("ibunescu/qa_legal_dataset_train")
16
 
17
  # Different pipelines for different tasks
 
82
  else:
83
  return "No clear winner"
84
 
85
+ # Custom CSS for a clean layout
86
  custom_css = """
87
  body {
88
  background-color: #ffffff;
 
194
  return pdf_files, pdf_text
195
 
196
  def get_top_10_cases():
197
+ summary = summarization_pipeline("Show 10 legal cases with names and numbers from any State Court of Appeals in the US.", max_length=150, min_length=50, do_sample=False)
198
+ return summary[0]['summary_text']
199
 
200
  def add_message(history, message):
201
  for x in message["files"]:
 
215
  response = ""
216
  for message in client.chat_completion(
217
  messages,
218
+ max_tokens=150,
219
  stream=True,
220
  temperature=0.6,
221
  top_p=0.95,
 
250
  with gr.Tab("Argument Evaluation"):
251
  with gr.Row():
252
  with gr.Column(scale=1):
253
+ top_10_btn = gr.Button("Give me the top 10 cases")
254
+ top_10_output = gr.Textbox(label="Top 10 Cases", interactive=False, elem_classes=["scroll-box"])
255
  top_10_btn.click(get_top_10_cases, outputs=top_10_output)
256
  with gr.Column(scale=2):
257
  message = gr.Textbox(label="Case to Argue")