robertselvam's picture
Update app.py
89fa8e9
raw
history blame
2.13 kB
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
with gr.Blocks(css="style.css",theme='xiaobaiyuan/theme_brief') as demo:
gr.HTML(
"""<hr style="border-top: 5px solid white;">"""
)
gr.HTML(
"""<br>
<h1 style="text-align:center;">
Contract Management
</h1> """
)
gr.HTML(
"""<hr style="border-top: 5px solid white;">"""
)
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 Extracter")
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 Extracter")
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 Extracter")
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 Extracter")
# pdf_to_json = gr.Textbox(label = "Pdf to Json")
# pdf_to_json_btn.click(PdftoJson.extract_text_from_pdf,upload_button,pdf_to_json)
demo.launch(debug=True)