Shredder commited on
Commit
f7ea213
1 Parent(s): 06d0b3f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -2
app.py CHANGED
@@ -1,4 +1,9 @@
1
  import gradio as gr
 
 
 
 
 
2
 
3
  def load_questions():
4
  questions = []
@@ -11,6 +16,16 @@ def con(file):
11
  with open(file.name) as f:
12
  text = f.read()
13
  return text
 
 
 
 
 
 
 
 
 
 
14
 
15
  demo = gr.Blocks()
16
  with demo:
@@ -18,6 +33,7 @@ with demo:
18
  text = gr.Textbox(lines=10)
19
  selected_ques=gr.Dropdown(choices=questions,label='SEARCH QUERY')
20
  b1 = gr.Button("Analyze File")
21
-
22
- b1.click(con, inputs=txt_file, outputs=text)
 
23
  demo.launch()
 
1
  import gradio as gr
2
+ import torch
3
+ from score_fincat import score_fincat
4
+ from sus_fls import get_sustainability,fls
5
+ from Cuad_others import quad,summarize_text,fin_ner
6
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
7
 
8
  def load_questions():
9
  questions = []
 
16
  with open(file.name) as f:
17
  text = f.read()
18
  return text
19
+
20
+ def mainFun(query,file):
21
+ text=''
22
+ with open(file.name) as f:
23
+ text = f.read()
24
+ answer,answer_p=quad(query,file.name)
25
+ return text,answer_p,summarize_text(answer)
26
+
27
+
28
+
29
 
30
  demo = gr.Blocks()
31
  with demo:
 
33
  text = gr.Textbox(lines=10)
34
  selected_ques=gr.Dropdown(choices=questions,label='SEARCH QUERY')
35
  b1 = gr.Button("Analyze File")
36
+ answer = gr.Textbox(lines=2)
37
+ summarize = gr.Textbox(lines=2)
38
+ b1.click(mainFun, inputs=[selected_ques,txt_file], outputs=[text,answer,summarize])
39
  demo.launch()