| import gradio as gr | |
| import torch | |
| from score_fincat import score_fincat | |
| from sus_fls import get_sustainability,fls | |
| from Cuad_others import quad,summarize_text,fin_ner | |
| device = torch.device("cuda" if torch.cuda.is_available() else "cpu") | |
| def load_questions(): | |
| questions = [] | |
| with open('questionshort.txt') as f: | |
| questions = f.readlines() | |
| return questions | |
| questions = load_questions() | |
| def con(file): | |
| with open(file.name) as f: | |
| text = f.read() | |
| return text | |
| def mainFun(query,file): | |
| text='' | |
| with open(file.name) as f: | |
| text = f.read() | |
| answer,answer_p=quad(query,file.name) | |
| return text,answer_p,summarize_text(answer) | |
| demo = gr.Blocks() | |
| with demo: | |
| txt_file = gr.File(label='CONTRACT') | |
| text = gr.Textbox(lines=10) | |
| selected_ques=gr.Dropdown(choices=questions,label='SEARCH QUERY') | |
| b1 = gr.Button("Analyze File") | |
| answer = gr.Textbox(lines=2) | |
| summarize = gr.Textbox(lines=2) | |
| b1.click(mainFun, inputs=[selected_ques,txt_file], outputs=[text,answer,summarize]) | |
| demo.launch() |