File size: 4,587 Bytes
5850aac
 
 
 
 
 
 
 
f121a7d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89fa8e9
e0549a6
 
 
f121a7d
e0549a6
 
f121a7d
 
 
 
 
 
5850aac
 
 
f121a7d
2c76c6c
f121a7d
 
5850aac
f121a7d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5850aac
f121a7d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5850aac
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
from summary_extractor import Extractor
from Tags_Extractor import Tags
from Clauses_Extractor import Clauses
from key_value_extractor import KeyValue
import openai
from pdftojson import PdftoJson
import gradio as gr

def file_output_fn(file_path):
    file_path = file_path.name
    return file_path

# with gr.Blocks(css="style.css",theme='xiaobaiyuan/theme_brief') as demo:
#     gr.HTML("""<center class="darkblue" style='background-color:#ad6e07; text-align:center;padding:25px;'>
#     <be>
#     <h1 style="color:#fff">
#         Contract Management 
#     </h1>
#     </center>""")  
#     with gr.Column(elem_id = "col-container",scale=0.10, min_width=160):
#         upload_button = gr.UploadButton(
#             "Browse File",file_types=[".txt", ".pdf", ".doc", ".docx",".json",".csv"],
#             elem_classes="filenameshow")
        
#         summary = gr.Textbox(label = "Summary")
#         extractor  = Extractor()

#         upload_button.upload( extractor._refine_summary,[upload_button],summary)
#     with gr.Tab("Tags"):
#         with gr.Column(elem_id = "col-container"):
#             tags_btn = gr.Button("Tags Extractor")
#             tags = gr.Textbox(lines=4,label = "Tags")
#             tags_btn.click(Tags.extract_tags,summary,tags)

#     with gr.Tab("Key Values"):
#         with gr.Column(elem_id = "col-container"):
#             key_value_btn = gr.Button("Key Value Extractor")
#             key_value = gr.Textbox(label = "Key Value")

#             key_value_btn.click( KeyValue.extract_key_value_pair,summary,key_value)

#     with gr.Tab("Clauses"):
#         with gr.Column(elem_id = "col-container"):
#             clauses_btn = gr.Button("Clauses Extractor")
#             clauses = gr.Textbox(label = "Clauses")
    
#             clauses_btn.click(Clauses.get_extracted_clauses,summary,clauses)

#     # with gr.Tab("pdf to json"):
#     #     with gr.Column(elem_id = "col-container"):
#     #         pdf_to_json_btn = gr.Button("pdf to json Extractor")
#     #         pdf_to_json = gr.Textbox(label = "Pdf to Json")
    
#     #         pdf_to_json_btn.click(PdftoJson.extract_text_from_pdf,upload_button,pdf_to_json)

with gr.Blocks(css="style.css",theme='xiaobaiyuan/theme_brief') as demo:
    gr.HTML("""<center class="darkblue" style='background-color:#ad6e07; text-align:center;padding:25px;'>
    <be>
    <h1 style="color:#fff">
        Contract 
    </h1>
    </center>""")  
    
    with gr.Row(elem_id = "col-container",scale=0.80):
      with gr.Column(elem_id = "col-container",scale=0.80):
        file_output = gr.File(label="File Status")
    
      with gr.Column(elem_id = "col-container",scale=0.20):  
        upload_button = gr.UploadButton(
            "Browse File",file_types=[".txt", ".pdf", ".doc", ".docx",".json",".csv"],
            elem_classes="filenameshow")
        summary_btn = gr.Button("Get Summary",elem_classes="filenameshow")
    
    with gr.Row(elem_id = "col-container",scale=0.60):    
        summary = gr.Textbox(label = "Summary")

    with gr.Row(elem_id = "col-container",scale=0.80):
        with gr.Tab("Tags"):
            with gr.Column(elem_id = "col-container",scale=0.80):
                tags_btn = gr.Button("Tags Extracter")
                tags = gr.Textbox(label = "Tags", lines=10)

        with gr.Tab("Key Values"):
            with gr.Column(elem_id = "col-container",scale=0.80):
                key_value_btn = gr.Button("Key Value Extracter")
                key_value = gr.Textbox(label = "Key Value",lines=10)


        with gr.Tab("Clauses"):
            with gr.Column(elem_id = "col-container",scale=0.80):
                clauses_btn = gr.Button("Clauses Extracter")
                clauses = gr.Textbox(label = "Clauses", lines=10)


        # with gr.Tab("pdf to json"):
        #     with gr.Column(elem_id = "col-container",scale=0.80):
        #         pdf_to_json_btn = gr.Button("pdf to json Extracter")
        #         pdf_to_json = gr.Textbox(label = "Pdf to Json", lines=10)
        
        #         # pdf_to_json_btn.click(PdftoJson.extract_text_from_pdf,upload_button,pdf_to_json)



    summary = gr.Textbox(label = "Summary")
    extractor  = Extractor()
          
    upload_button.upload(file_output_fn,upload_button,file_output)
    summary_btn.upload( extractor._refine_summary,[upload_button],summary)  
    
    tags_btn.click(Tags.extract_tags,summary,tags)
    key_value_btn.click( KeyValue.extract_key_value_pair,summary,key_value)
    clauses_btn.click(Clauses.get_extracted_clauses,summary,clauses)
    
demo.launch(debug=True)