Spaces:
Running
Running
robertselvam
commited on
Commit
•
5850aac
1
Parent(s):
677ad5a
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from summary_extractor import Extractor
|
2 |
+
from Tags_Extractor import Tags
|
3 |
+
from Clauses_Extractor import Clauses
|
4 |
+
from key_value_extractor import KeyValue
|
5 |
+
import openai
|
6 |
+
from pdftojson import PdftoJson
|
7 |
+
import gradio as gr
|
8 |
+
|
9 |
+
with gr.Blocks(css="style.css",theme=gr.themes.Soft()) as demo:
|
10 |
+
gr.HTML(
|
11 |
+
"""<hr style="border-top: 5px solid white;">"""
|
12 |
+
)
|
13 |
+
gr.HTML(
|
14 |
+
"""<br>
|
15 |
+
<h1 style="text-align:center;">
|
16 |
+
Contract Management
|
17 |
+
</h1> """
|
18 |
+
)
|
19 |
+
gr.HTML(
|
20 |
+
"""<hr style="border-top: 5px solid white;">"""
|
21 |
+
)
|
22 |
+
with gr.Column(scale=0.10, min_width=160):
|
23 |
+
upload_button = gr.UploadButton(
|
24 |
+
"Browse File",file_types=[".txt", ".pdf", ".doc", ".docx",".json",".csv"],
|
25 |
+
elem_classes="filenameshow")
|
26 |
+
|
27 |
+
summary = gr.Textbox(label = "Summary")
|
28 |
+
extractor = Extractor()
|
29 |
+
|
30 |
+
upload_button.upload( extractor._refine_summary,[upload_button],summary)
|
31 |
+
with gr.Tab("Tags"):
|
32 |
+
tags_btn = gr.Button("Tags Extracter")
|
33 |
+
tags = gr.Textbox(lines=4,label = "Tags")
|
34 |
+
tags_btn.click(Tags.extract_tags,summary,tags)
|
35 |
+
|
36 |
+
with gr.Tab("Key Values"):
|
37 |
+
key_value_btn = gr.Button("Key Value Extracter")
|
38 |
+
key_value = gr.Textbox(label = "Key Value")
|
39 |
+
|
40 |
+
key_value_btn.click( KeyValue.extract_key_value_pair,summary,key_value)
|
41 |
+
|
42 |
+
with gr.Tab("Clauses"):
|
43 |
+
clauses_btn = gr.Button("Clauses Extracter")
|
44 |
+
clauses = gr.Textbox(label = "Clauses")
|
45 |
+
|
46 |
+
clauses_btn.click(Clauses.get_extracted_clauses,summary,clauses)
|
47 |
+
|
48 |
+
with gr.Tab("pdf to json"):
|
49 |
+
pdf_to_json_btn = gr.Button("pdf to json Extracter")
|
50 |
+
pdf_to_json = gr.Textbox(label = "Pdf to Json")
|
51 |
+
|
52 |
+
pdf_to_json_btn.click(PdftoJson.extract_text_from_pdf,summary,pdf_to_json)
|
53 |
+
|
54 |
+
|
55 |
+
demo.launch(debug=True)
|