dammy commited on
Commit
4627abd
·
1 Parent(s): 3c8742c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -10,7 +10,7 @@ import uuid
10
  from sentence_transformers import SentenceTransformer
11
  import os
12
 
13
- f =''
14
  model_name = 'google/flan-t5-base'
15
  model = T5ForConditionalGeneration.from_pretrained(model_name, device_map='auto', offload_folder="offload")
16
  tokenizer = AutoTokenizer.from_pretrained(model_name)
@@ -42,9 +42,9 @@ def local_query(query, context):
42
 
43
  return tokenizer.batch_decode(outputs, skip_special_tokens=True)
44
 
45
- def run_query(history, query):
46
 
47
- file_name = f.name
48
 
49
  loader = PDFMinerLoader(file_name)
50
  doc = loader.load()
@@ -90,7 +90,7 @@ def run_query(history, query):
90
  def upload_pdf(file):
91
  try:
92
  if file is not None:
93
- f = file
94
  return 'Successfully uploaded!'
95
  else:
96
  return "No file uploaded."
@@ -118,7 +118,7 @@ with gr.Blocks() as demo:
118
 
119
  # Event handler for uploading a PDF
120
  btn.upload(fn=upload_pdf, inputs=[btn], outputs=[output])
121
- txt.submit(run_query, [chatbot, txt], [chatbot, txt])
122
  #.then(
123
  # generate_response, inputs =[chatbot,],outputs = chatbot,)
124
 
 
10
  from sentence_transformers import SentenceTransformer
11
  import os
12
 
13
+
14
  model_name = 'google/flan-t5-base'
15
  model = T5ForConditionalGeneration.from_pretrained(model_name, device_map='auto', offload_folder="offload")
16
  tokenizer = AutoTokenizer.from_pretrained(model_name)
 
42
 
43
  return tokenizer.batch_decode(outputs, skip_special_tokens=True)
44
 
45
+ def run_query(btn, history, query):
46
 
47
+ file_name = btn.name
48
 
49
  loader = PDFMinerLoader(file_name)
50
  doc = loader.load()
 
90
  def upload_pdf(file):
91
  try:
92
  if file is not None:
93
+
94
  return 'Successfully uploaded!'
95
  else:
96
  return "No file uploaded."
 
118
 
119
  # Event handler for uploading a PDF
120
  btn.upload(fn=upload_pdf, inputs=[btn], outputs=[output])
121
+ txt.submit(run_query, [btn, chatbot, txt], [btn, chatbot, txt])
122
  #.then(
123
  # generate_response, inputs =[chatbot,],outputs = chatbot,)
124