Spaces:
Running
Running
robertselvam
commited on
Commit
•
f121a7d
1
Parent(s):
6d5176d
Update app.py
Browse files
app.py
CHANGED
@@ -6,48 +6,109 @@ import openai
|
|
6 |
from pdftojson import PdftoJson
|
7 |
import gradio as gr
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
with gr.Blocks(css="style.css",theme='xiaobaiyuan/theme_brief') as demo:
|
10 |
gr.HTML("""<center class="darkblue" style='background-color:#ad6e07; text-align:center;padding:25px;'>
|
11 |
<be>
|
12 |
<h1 style="color:#fff">
|
13 |
-
Contract
|
14 |
</h1>
|
15 |
</center>""")
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
17 |
upload_button = gr.UploadButton(
|
18 |
"Browse File",file_types=[".txt", ".pdf", ".doc", ".docx",".json",".csv"],
|
19 |
elem_classes="filenameshow")
|
20 |
-
|
21 |
-
summary = gr.Textbox(label = "Summary")
|
22 |
-
extractor = Extractor()
|
23 |
-
|
24 |
-
upload_button.upload( extractor._refine_summary,[upload_button],summary)
|
25 |
-
with gr.Tab("Tags"):
|
26 |
-
with gr.Column(elem_id = "col-container"):
|
27 |
-
tags_btn = gr.Button("Tags Extractor")
|
28 |
-
tags = gr.Textbox(lines=4,label = "Tags")
|
29 |
-
tags_btn.click(Tags.extract_tags,summary,tags)
|
30 |
-
|
31 |
-
with gr.Tab("Key Values"):
|
32 |
-
with gr.Column(elem_id = "col-container"):
|
33 |
-
key_value_btn = gr.Button("Key Value Extractor")
|
34 |
-
key_value = gr.Textbox(label = "Key Value")
|
35 |
-
|
36 |
-
key_value_btn.click( KeyValue.extract_key_value_pair,summary,key_value)
|
37 |
-
|
38 |
-
with gr.Tab("Clauses"):
|
39 |
-
with gr.Column(elem_id = "col-container"):
|
40 |
-
clauses_btn = gr.Button("Clauses Extractor")
|
41 |
-
clauses = gr.Textbox(label = "Clauses")
|
42 |
|
43 |
-
|
|
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
demo.launch(debug=True)
|
|
|
6 |
from pdftojson import PdftoJson
|
7 |
import gradio as gr
|
8 |
|
9 |
+
def file_output_fn(file_path):
|
10 |
+
file_path = file_path.name
|
11 |
+
return file_path
|
12 |
+
|
13 |
+
# with gr.Blocks(css="style.css",theme='xiaobaiyuan/theme_brief') as demo:
|
14 |
+
# gr.HTML("""<center class="darkblue" style='background-color:#ad6e07; text-align:center;padding:25px;'>
|
15 |
+
# <be>
|
16 |
+
# <h1 style="color:#fff">
|
17 |
+
# Contract Management
|
18 |
+
# </h1>
|
19 |
+
# </center>""")
|
20 |
+
# with gr.Column(elem_id = "col-container",scale=0.10, min_width=160):
|
21 |
+
# upload_button = gr.UploadButton(
|
22 |
+
# "Browse File",file_types=[".txt", ".pdf", ".doc", ".docx",".json",".csv"],
|
23 |
+
# elem_classes="filenameshow")
|
24 |
+
|
25 |
+
# summary = gr.Textbox(label = "Summary")
|
26 |
+
# extractor = Extractor()
|
27 |
+
|
28 |
+
# upload_button.upload( extractor._refine_summary,[upload_button],summary)
|
29 |
+
# with gr.Tab("Tags"):
|
30 |
+
# with gr.Column(elem_id = "col-container"):
|
31 |
+
# tags_btn = gr.Button("Tags Extractor")
|
32 |
+
# tags = gr.Textbox(lines=4,label = "Tags")
|
33 |
+
# tags_btn.click(Tags.extract_tags,summary,tags)
|
34 |
+
|
35 |
+
# with gr.Tab("Key Values"):
|
36 |
+
# with gr.Column(elem_id = "col-container"):
|
37 |
+
# key_value_btn = gr.Button("Key Value Extractor")
|
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 |
+
# with gr.Column(elem_id = "col-container"):
|
44 |
+
# clauses_btn = gr.Button("Clauses Extractor")
|
45 |
+
# clauses = gr.Textbox(label = "Clauses")
|
46 |
+
|
47 |
+
# clauses_btn.click(Clauses.get_extracted_clauses,summary,clauses)
|
48 |
+
|
49 |
+
# # with gr.Tab("pdf to json"):
|
50 |
+
# # with gr.Column(elem_id = "col-container"):
|
51 |
+
# # pdf_to_json_btn = gr.Button("pdf to json Extractor")
|
52 |
+
# # pdf_to_json = gr.Textbox(label = "Pdf to Json")
|
53 |
+
|
54 |
+
# # pdf_to_json_btn.click(PdftoJson.extract_text_from_pdf,upload_button,pdf_to_json)
|
55 |
+
|
56 |
with gr.Blocks(css="style.css",theme='xiaobaiyuan/theme_brief') as demo:
|
57 |
gr.HTML("""<center class="darkblue" style='background-color:#ad6e07; text-align:center;padding:25px;'>
|
58 |
<be>
|
59 |
<h1 style="color:#fff">
|
60 |
+
Contract
|
61 |
</h1>
|
62 |
</center>""")
|
63 |
+
|
64 |
+
with gr.Row(elem_id = "col-container",scale=0.80):
|
65 |
+
with gr.Column(elem_id = "col-container",scale=0.80):
|
66 |
+
file_output = gr.File(label="File Status")
|
67 |
+
|
68 |
+
with gr.Column(elem_id = "col-container",scale=0.20):
|
69 |
upload_button = gr.UploadButton(
|
70 |
"Browse File",file_types=[".txt", ".pdf", ".doc", ".docx",".json",".csv"],
|
71 |
elem_classes="filenameshow")
|
72 |
+
summary_btn = gr.Button("Get Summary",elem_classes="filenameshow")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
+
with gr.Row(elem_id = "col-container",scale=0.60):
|
75 |
+
summary = gr.Textbox(label = "Summary")
|
76 |
|
77 |
+
with gr.Row(elem_id = "col-container",scale=0.80):
|
78 |
+
with gr.Tab("Tags"):
|
79 |
+
with gr.Column(elem_id = "col-container",scale=0.80):
|
80 |
+
tags_btn = gr.Button("Tags Extracter")
|
81 |
+
tags = gr.Textbox(label = "Tags", lines=10)
|
82 |
+
|
83 |
+
with gr.Tab("Key Values"):
|
84 |
+
with gr.Column(elem_id = "col-container",scale=0.80):
|
85 |
+
key_value_btn = gr.Button("Key Value Extracter")
|
86 |
+
key_value = gr.Textbox(label = "Key Value",lines=10)
|
87 |
+
|
88 |
+
|
89 |
+
with gr.Tab("Clauses"):
|
90 |
+
with gr.Column(elem_id = "col-container",scale=0.80):
|
91 |
+
clauses_btn = gr.Button("Clauses Extracter")
|
92 |
+
clauses = gr.Textbox(label = "Clauses", lines=10)
|
93 |
|
94 |
+
|
95 |
+
# with gr.Tab("pdf to json"):
|
96 |
+
# with gr.Column(elem_id = "col-container",scale=0.80):
|
97 |
+
# pdf_to_json_btn = gr.Button("pdf to json Extracter")
|
98 |
+
# pdf_to_json = gr.Textbox(label = "Pdf to Json", lines=10)
|
99 |
+
|
100 |
+
# # pdf_to_json_btn.click(PdftoJson.extract_text_from_pdf,upload_button,pdf_to_json)
|
101 |
+
|
102 |
+
|
103 |
+
|
104 |
+
summary = gr.Textbox(label = "Summary")
|
105 |
+
extractor = Extractor()
|
106 |
+
|
107 |
+
upload_button.upload(file_output_fn,upload_button,file_output)
|
108 |
+
summary_btn.upload( extractor._refine_summary,[upload_button],summary)
|
109 |
+
|
110 |
+
tags_btn.click(Tags.extract_tags,summary,tags)
|
111 |
+
key_value_btn.click( KeyValue.extract_key_value_pair,summary,key_value)
|
112 |
+
clauses_btn.click(Clauses.get_extracted_clauses,summary,clauses)
|
113 |
|
114 |
demo.launch(debug=True)
|