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("""

Contract

""") with gr.Tab("Contract Summary"): 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") 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) 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) with gr.Tab("pdf"): with gr.Row(elem_id = "col-container",scale=0.80): with gr.Column(elem_id = "col-container",scale=0.80): file_output1 = gr.File(label="File Status",elem_classes="filenameshow") with gr.Column(elem_id = "col-container",scale=0.20): upload_button1 = gr.UploadButton( "Browse File",file_types=[".txt", ".pdf", ".doc", ".docx",".json",".csv"], elem_classes="uploadbutton") headings_btn = gr.Button("Get Headings",elem_classes="uploadbutton") with gr.Row(elem_id = "col-container",scale=0.60): headings = gr.Textbox(label = "Headings") upload_button.upload(file_output_fn,upload_button,file_output) headings_btn.click(HeadingsExtractor.extarct_text,upload_button1,headings) demo.launch(debug=True)