File size: 5,997 Bytes
5850aac
 
 
 
7e22cdc
5850aac
fb2e939
df6541f
 
417a9e0
 
 
 
5850aac
 
f121a7d
 
 
 
cecc821
b9945b8
f933609
e0549a6
2c5ad03
f121a7d
e0549a6
 
021aa42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55623d1
021aa42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
417a9e0
 
 
57c9413
417a9e0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
021aa42
 
 
34fed9c
021aa42
 
 
 
 
 
 
34fed9c
021aa42
 
34fed9c
021aa42
 
34fed9c
021aa42
417a9e0
 
 
 
 
 
 
 
 
 
 
 
95a7d16
417a9e0
 
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
from summary_extractor import Extractor
from Tags_Extractor import Tags
from Clauses_Extractor import Clauses
from key_value_extractor import KeyValue
from incorrect_sentence_finder import IncorrectSentenceFinder
from pdftojson import PdftoJson
from headings_extractor import HeadingsExtractor
from incompletesentencefinder import IncompleteSentenceFinder
from aggressive_content_finder import AggressiveContentFinder
from extract_date import ExtractDateAndDuration
from pdftojson import PdftoJson
from ContractGenerator import ContractGenerator
from contract_missing_clausses import ContractMissingClauses
import gradio as gr

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

#xiaobaiyuan/theme_land  earneleh/paris
with gr.Blocks(css="style.css",theme='freddyaboulton/test-blue') as demo: 
    gr.HTML("""<center class="darkblue" text-align:center;padding:25px;'>
    <be>
    <h1 style="color:#fff; font-weight:bold; font-size:28px;">
        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",elem_classes="filenameshow")
    
      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="uploadbutton")
        summary_btn = gr.Button("Get Summary",elem_classes="uploadbutton")
    
    with gr.Row(elem_id = "col-container",scale=0.60):    
        summary = gr.Textbox(label = "Summary",lines=10)

    with gr.Row(elem_id = "col-container",scale=0.80):
        with gr.TabItem("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.TabItem("Key Values"):
            with gr.Column(elem_id = "col-container",scale=0.80):
                key_value_btn = gr.Button("Key Value Extractor")
                key_value = gr.Textbox(label = "Key Value",lines=10)


        with gr.TabItem("Clauses"):
            with gr.Column(elem_id = "col-container",scale=0.80):
                clauses_btn = gr.Button("Clauses Extractor")
                clauses = gr.Textbox(label = "Clauses", lines=10)
                
        with gr.TabItem("Headings"):
            with gr.Column(elem_id = "col-container",scale=0.80):  
                heading_btn = gr.Button("Headings Extractor")
                heading = gr.Textbox(label = "Headings", lines=10)
                
        with gr.TabItem("Incorrect_Sentence"): 
            with gr.Column(elem_id = "col-container",scale=0.80):  
                incor_sen_btn = gr.Button("Incorrect Sentence Extractor")
                incorrect_sentence = gr.Textbox(label = "Incorrect Sentence", lines=10)
          
        with gr.TabItem("Incomplete Sentence"):   
            with gr.Column(elem_id = "col-container",scale=0.80):  
                incom_sen_btn = gr.Button("Incomplete Sentence Extractor")
                incomplete_sentence = gr.Textbox(label = "Incomplete Sentence", lines=10)
                
        with gr.TabItem("Aggressive Content"):
            with gr.Column(elem_id = "col-container",scale=0.80):  
                aggres_sen_btn = gr.Button("Aggressive Content Extractor")
                aggressive_sentence = gr.Textbox(label = "Aggressive Content", lines=10)   
                
        with gr.TabItem("Extract Date"):
            with gr.Column(elem_id = "col-container",scale=0.80):  
                extract_date_btn = gr.Button("Extract date")
                extracted_date = gr.Textbox(label = "Extract date", lines=10) 

        with gr.TabItem("Pdf to Json"):
            with gr.Column(elem_id = "col-container",scale=0.80):  
                extract_json_btn = gr.Button("Extract Json from PDF")
                extracted_json = gr.Textbox(label = "Json", lines=10)   

        with gr.TabItem("Contract Generator"):
            with gr.Column(elem_id = "col-container",scale=0.80):  
                prompt = gr.Textbox(label="Prompt")
                generate_btn = gr.Button("Generate")
                contract_box = gr.Textbox(label = "Contract", lines=10)   

        with gr.TabItem("Missing Features"):
            with gr.Column(elem_id = "col-container",scale=0.80):  
                find_missing_features_btn = gr.Button("Find Missing Features")
                Output_box = gr.Textbox(label = "Output", lines=10)   
                
    extractor  = Extractor() 
    upload_button.upload(file_output_fn,upload_button,file_output)
    summary_btn.click( 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)
    
    ex= HeadingsExtractor()
    heading_btn.click(ex.extract_text,upload_button,heading)

    inf= IncorrectSentenceFinder()
    incor_sen_btn.click(inf.get_incorrect_sentence,upload_button,incorrect_sentence)

    inc= IncompleteSentenceFinder()
    incom_sen_btn.click(inc.get_incomplete_sentence,upload_button,incomplete_sentence)

    agg= AggressiveContentFinder()
    aggres_sen_btn.click(agg.get_aggressive_content,upload_button,aggressive_sentence)    

    date =  ExtractDateAndDuration()
    extract_date_btn.click(date.itrate_each_page,upload_button,extracted_date)

    pdftojson = PdftoJson()
    extract_json_btn.click(pdftojson.extract_text_from_pdf,upload_button,extracted_json)

    contract_gen = ContractGenerator()
    generate_btn.click(contract_gen.generate_contract,prompt,contract_box)

    cont_mis_clauses = ContractMissingClauses()
    find_missing_features_btn.click(cont_mis_clauses.iterate_each_page,upload_button,Output_box)


demo.launch(debug=True)