Spaces:
Running
Running
File size: 3,649 Bytes
5850aac 7e22cdc 5850aac fb2e939 df6541f 5850aac 449d0b9 f121a7d 449d0b9 f121a7d 18f7ce9 e0549a6 f121a7d e0549a6 16a8734 c03e845 f73df00 c03e845 b3b67ed c03e845 f73df00 b3b67ed c03e845 d47f161 49d9345 b3b67ed c03e845 49d9345 c03e845 1bf7aef df6541f 1bf7aef df6541f 4f1c5df 102cdee f5bebd9 ccf92e5 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 |
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
import openai
from pdftojson import PdftoJson
from headings_extractor import HeadingsExtractor
from incompletesentencefinder import IncompleteSentenceFinder
from aggressive_content_finder import AggressiveContentFinder
import gradio as gr
overall_filepath = ''
def file_output_fn(file_path):
file_path = file_path.name
global overall_filepath
print("before",file_path)
overall_filepath = file_path
print("after",overall_filepath)
return file_path
with gr.Blocks(css="style.css",theme='xiaobaiyuan/theme_land') 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.Tabs():
with gr.TabItem("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.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 Extracter")
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 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.TabItem("pdf"):
ex= HeadingsExtractor()
ex.gradio_interface()
with gr.TabItem("Incorrect_Sentence"):
inf= IncorrectSentenceFinder()
inf.gradio_interface()
with gr.TabItem("Incomplete Sentence"):
inc= IncompleteSentenceFinder()
inc.gradio_interface()
with gr.TabItem("Aggressive Content"):
agg= AggressiveContentFinder(overall_filepath)
agg.gradio_interface()
demo.launch(debug=True) |