ABDALLAH31 commited on
Commit
9127116
·
verified ·
1 Parent(s): 95bf8db

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -26
app.py CHANGED
@@ -1,15 +1,6 @@
1
- import gradio as gr
2
- import base64
3
- import tempfile
4
- from utils import extract_text_from_pdf, simple_clause_split
5
- from model import classify_clauses
6
- from report import generate_pdf
7
- from salesforce_stub import send_to_salesforce
8
-
9
  def analyze_contract(file):
10
- with tempfile.NamedTemporaryFile(delete=False, suffix=".pdf") as tmp:
11
- tmp.write(file.read())
12
- tmp_path = tmp.name
13
 
14
  text = extract_text_from_pdf(tmp_path)
15
  clauses = simple_clause_split(text)
@@ -34,18 +25,3 @@ def analyze_contract(file):
34
  })
35
 
36
  return f"Overall Risk Score: {overall_score:.2f}", highlight_output, report_path
37
-
38
- iface = gr.Interface(
39
- fn=analyze_contract,
40
- inputs=gr.File(label="Upload Contract PDF"),
41
- outputs=[
42
- gr.Textbox(label="Overall Risk Score"),
43
- gr.HTML(label="Clause Risk Highlight"),
44
- gr.File(label="Download Risk Report (PDF)")
45
- ],
46
- title="📜 Contract Risk Heatmap Generator",
47
- description="Upload a contract and get clause-level risk scores with heatmap-style highlights. Powered by Hugging Face Transformers."
48
- )
49
-
50
- if __name__ == "__main__":
51
- iface.launch()
 
 
 
 
 
 
 
 
 
1
  def analyze_contract(file):
2
+ # Hugging Face provides `file.name` (a path to the uploaded file)
3
+ tmp_path = file.name
 
4
 
5
  text = extract_text_from_pdf(tmp_path)
6
  clauses = simple_clause_split(text)
 
25
  })
26
 
27
  return f"Overall Risk Score: {overall_score:.2f}", highlight_output, report_path