dammy commited on
Commit
5573a68
·
1 Parent(s): 20d9611

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -14
app.py CHANGED
@@ -10,15 +10,15 @@ import gradio as gr
10
  import uuid
11
  from sentence_transformers import SentenceTransformer
12
 
13
- model_name = 'google/flan-t5-base'
14
- model = T5ForConditionalGeneration.from_pretrained(model_name, device_map='auto', offload_folder="offload")
15
- tokenizer = AutoTokenizer.from_pretrained(model_name)
16
- print('flan read')
17
 
18
 
19
- ST_name = 'sentence-transformers/sentence-t5-base'
20
- st_model = SentenceTransformer(ST_name)
21
- print('sentence read')
22
 
23
 
24
  def get_context(query_text):
@@ -46,13 +46,8 @@ def run_query(query):
46
  return result
47
 
48
 
49
-
50
- def upload_pdf(file):
51
- # Save the uploaded file
52
- file_name = file.name
53
- pdf_filename = os.path.basename(file_path)
54
 
55
- # Load a document
56
  loader = PDFMinerLoader(pdf_filename)
57
  doc = loader.load()
58
 
@@ -75,7 +70,18 @@ def upload_pdf(file):
75
  ids=ids
76
  )
77
 
78
- return 'hello'
 
 
 
 
 
 
 
 
 
 
 
79
 
80
 
81
 
 
10
  import uuid
11
  from sentence_transformers import SentenceTransformer
12
 
13
+ # model_name = 'google/flan-t5-base'
14
+ # model = T5ForConditionalGeneration.from_pretrained(model_name, device_map='auto', offload_folder="offload")
15
+ # tokenizer = AutoTokenizer.from_pretrained(model_name)
16
+ # print('flan read')
17
 
18
 
19
+ # ST_name = 'sentence-transformers/sentence-t5-base'
20
+ # st_model = SentenceTransformer(ST_name)
21
+ # print('sentence read')
22
 
23
 
24
  def get_context(query_text):
 
46
  return result
47
 
48
 
49
+ def load_document(pdf_filename):
 
 
 
 
50
 
 
51
  loader = PDFMinerLoader(pdf_filename)
52
  doc = loader.load()
53
 
 
70
  ids=ids
71
  )
72
 
73
+ return 'Success'
74
+
75
+
76
+ def upload_pdf(file):
77
+ # Save the uploaded file
78
+ file_name = file.name
79
+ pdf_filename = os.path.basename(file_path)
80
+
81
+ messsage = load_document(pdf_filename)
82
+
83
+
84
+ return messsage
85
 
86
 
87