Omnibus commited on
Commit
46cc42f
·
1 Parent(s): c8c3bdc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -5
app.py CHANGED
@@ -25,6 +25,18 @@ client = InferenceClient(
25
  "mistralai/Mixtral-8x7B-Instruct-v0.1"
26
  )
27
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  def parse_action(string: str):
29
  print("PARSING:")
30
  print(string)
@@ -152,6 +164,8 @@ def compress_data(c, instruct, history):
152
 
153
  def summarize(inp,history,data=None,file=None):
154
  #file = None
 
 
155
  if inp == "":
156
  inp = "Process this data"
157
 
@@ -160,11 +174,11 @@ def summarize(inp,history,data=None,file=None):
160
  yield "",history
161
  if file:
162
  try:
163
- with open(file,"r") as f:
164
- zz=f.readlines()
165
- f.close
166
- print (zz)
167
- data=f'{data}\nFile:\n{zz}'
168
  except Exception as e:
169
  print (e)
170
 
 
25
  "mistralai/Mixtral-8x7B-Instruct-v0.1"
26
  )
27
 
28
+
29
+ def read_pdf(pdf_path):
30
+ from pypdf import PdfReader
31
+
32
+ reader = PdfReader(f'{pdf_path}')
33
+ number_of_pages = len(reader.pages)
34
+
35
+ page = reader.pages[:-1]
36
+ text = page.extract_text()
37
+ print (text)
38
+ return text
39
+
40
  def parse_action(string: str):
41
  print("PARSING:")
42
  print(string)
 
164
 
165
  def summarize(inp,history,data=None,file=None):
166
  #file = None
167
+
168
+
169
  if inp == "":
170
  inp = "Process this data"
171
 
 
174
  yield "",history
175
  if file:
176
  try:
177
+ print (file)
178
+ if file.endswith(".pdf"):
179
+ zz=read_pdf(file)
180
+ print (zz)
181
+ data=f'{data}\nFile:\n{zz}'
182
  except Exception as e:
183
  print (e)
184