Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -298,158 +298,6 @@ def extract_pdf_text_and_embedding():
|
|
298 |
print(e)
|
299 |
return jsonify({"error": str(list)}), 500
|
300 |
|
301 |
-
@cache.cached(timeout=300)
|
302 |
-
@app.route('/extract_pdf_text_and_embedding1', methods=['POST'])
|
303 |
-
def extract_pdf_text_and_embedding():
|
304 |
-
list = []
|
305 |
-
try:
|
306 |
-
list.append(1)
|
307 |
-
pdf_url = request.json.get("pdfUrl")
|
308 |
-
list.append(2)
|
309 |
-
print(1)
|
310 |
-
return jsonify({"content":str(list)}) , 200
|
311 |
-
# pages_info = "Error"
|
312 |
-
# try :
|
313 |
-
# pages_info = seperate_image_text_from_pdf(pdf_url)
|
314 |
-
# except Exception as e:
|
315 |
-
# print(e)
|
316 |
-
# return jsonify({"error": "Failed to fetch the PDF from the URL"}), 500
|
317 |
-
# list.append(3)
|
318 |
-
# if(pages_info == "Error"):
|
319 |
-
# return jsonify({"error": "Failed to fetch the PDF from the URL seperate_image_text_from_pdf "}), 500
|
320 |
-
# list.append(4)
|
321 |
-
# content = pdf_image_text_embedding_and_text_embedding(pages_info)
|
322 |
-
# if content == "Error":
|
323 |
-
# return jsonify({"error": "An error occurred while processing the PDF"}), 500
|
324 |
-
# list.append(5)
|
325 |
-
# print(content)
|
326 |
-
# return jsonify({"content": content}), 200
|
327 |
-
|
328 |
-
except Exception as e:
|
329 |
-
print(e)
|
330 |
-
return jsonify({"error": str(list)}), 500
|
331 |
-
|
332 |
-
@cache.cached(timeout=300)
|
333 |
-
@app.route('/extract_pdf_text_and_embedding2', methods=['POST'])
|
334 |
-
def extract_pdf_text_and_embedding():
|
335 |
-
list = []
|
336 |
-
try:
|
337 |
-
list.append(1)
|
338 |
-
pdf_url = request.json.get("pdfUrl")
|
339 |
-
list.append(2)
|
340 |
-
print(1)
|
341 |
-
return jsonify({"content":str(list)}) , 200
|
342 |
-
pages_info = "Error"
|
343 |
-
try :
|
344 |
-
pages_info = seperate_image_text_from_pdf(pdf_url)
|
345 |
-
except Exception as e:
|
346 |
-
return jsonify({"content":str(list)}) , 200
|
347 |
-
# list.append(3)
|
348 |
-
# if(pages_info == "Error"):
|
349 |
-
# return jsonify({"error": "Failed to fetch the PDF from the URL seperate_image_text_from_pdf "}), 500
|
350 |
-
# list.append(4)
|
351 |
-
# content = pdf_image_text_embedding_and_text_embedding(pages_info)
|
352 |
-
# if content == "Error":
|
353 |
-
# return jsonify({"error": "An error occurred while processing the PDF"}), 500
|
354 |
-
# list.append(5)
|
355 |
-
# print(content)
|
356 |
-
# return jsonify({"content": content}), 200
|
357 |
-
|
358 |
-
except Exception as e:
|
359 |
-
print(e)
|
360 |
-
return jsonify({"error": str(list)}), 500
|
361 |
-
|
362 |
-
@cache.cached(timeout=300)
|
363 |
-
@app.route('/extract_pdf_text_and_embedding3', methods=['POST'])
|
364 |
-
def extract_pdf_text_and_embedding():
|
365 |
-
list = []
|
366 |
-
try:
|
367 |
-
list.append(1)
|
368 |
-
pdf_url = request.json.get("pdfUrl")
|
369 |
-
list.append(2)
|
370 |
-
print(1)
|
371 |
-
return jsonify({"content":str(list)}) , 200
|
372 |
-
pages_info = "Error"
|
373 |
-
try :
|
374 |
-
pages_info = seperate_image_text_from_pdf(pdf_url)
|
375 |
-
except Exception as e:
|
376 |
-
return jsonify({"content":str(list)}) , 200
|
377 |
-
list.append(3)
|
378 |
-
if(pages_info == "Error"):
|
379 |
-
return jsonify({"content":str(list)}) , 200
|
380 |
-
# list.append(4)
|
381 |
-
# content = pdf_image_text_embedding_and_text_embedding(pages_info)
|
382 |
-
# if content == "Error":
|
383 |
-
# return jsonify({"error": "An error occurred while processing the PDF"}), 500
|
384 |
-
# list.append(5)
|
385 |
-
# print(content)
|
386 |
-
# return jsonify({"content": content}), 200
|
387 |
-
|
388 |
-
except Exception as e:
|
389 |
-
print(e)
|
390 |
-
return jsonify({"error": str(list)}), 500
|
391 |
-
|
392 |
-
@cache.cached(timeout=300)
|
393 |
-
@app.route('/extract_pdf_text_and_embedding4', methods=['POST'])
|
394 |
-
def extract_pdf_text_and_embedding():
|
395 |
-
list = []
|
396 |
-
try:
|
397 |
-
list.append(1)
|
398 |
-
pdf_url = request.json.get("pdfUrl")
|
399 |
-
list.append(2)
|
400 |
-
print(1)
|
401 |
-
return jsonify({"content":str(list)}) , 200
|
402 |
-
pages_info = "Error"
|
403 |
-
try :
|
404 |
-
pages_info = seperate_image_text_from_pdf(pdf_url)
|
405 |
-
except Exception as e:
|
406 |
-
return jsonify({"content":str(list)}) , 200
|
407 |
-
list.append(3)
|
408 |
-
if(pages_info == "Error"):
|
409 |
-
return jsonify({"content":str(list)}) , 200
|
410 |
-
list.append(4)
|
411 |
-
content = pdf_image_text_embedding_and_text_embedding(pages_info)
|
412 |
-
if content == "Error":
|
413 |
-
return jsonify({"content":str(list)}) , 200
|
414 |
-
# list.append(5)
|
415 |
-
# print(content)
|
416 |
-
# return jsonify({"content": content}), 200
|
417 |
-
|
418 |
-
except Exception as e:
|
419 |
-
print(e)
|
420 |
-
return jsonify({"error": str(list)}), 500
|
421 |
-
|
422 |
-
|
423 |
-
@cache.cached(timeout=300)
|
424 |
-
@app.route('/extract_pdf_text_and_embedding5', methods=['POST'])
|
425 |
-
def extract_pdf_text_and_embedding():
|
426 |
-
list = []
|
427 |
-
try:
|
428 |
-
list.append(1)
|
429 |
-
pdf_url = request.json.get("pdfUrl")
|
430 |
-
list.append(2)
|
431 |
-
print(1)
|
432 |
-
return jsonify({"content":str(list)}) , 200
|
433 |
-
pages_info = "Error"
|
434 |
-
try :
|
435 |
-
pages_info = seperate_image_text_from_pdf(pdf_url)
|
436 |
-
except Exception as e:
|
437 |
-
return jsonify({"content":str(list)}) , 200
|
438 |
-
list.append(3)
|
439 |
-
if(pages_info == "Error"):
|
440 |
-
return jsonify({"content":str(list)}) , 200
|
441 |
-
list.append(4)
|
442 |
-
content = pdf_image_text_embedding_and_text_embedding(pages_info)
|
443 |
-
if content == "Error":
|
444 |
-
return jsonify({"content":str(list)}) , 200
|
445 |
-
list.append(5)
|
446 |
-
print(content)
|
447 |
-
return jsonify({"content": content}), 200
|
448 |
-
|
449 |
-
except Exception as e:
|
450 |
-
print(e)
|
451 |
-
return jsonify({"error": str(list)}), 500
|
452 |
-
|
453 |
# Route to get text description embeddings
|
454 |
@cache.cached(timeout=300)
|
455 |
@app.route('/getTextDescriptionEmbedding', methods=['POST'])
|
@@ -513,5 +361,4 @@ def get_similarity_score_route():
|
|
513 |
return jsonify({"similarity_score": similarity_score}), 200
|
514 |
|
515 |
except Exception as e:
|
516 |
-
return jsonify({"error": str(e)}), 500
|
517 |
-
|
|
|
298 |
print(e)
|
299 |
return jsonify({"error": str(list)}), 500
|
300 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
301 |
# Route to get text description embeddings
|
302 |
@cache.cached(timeout=300)
|
303 |
@app.route('/getTextDescriptionEmbedding', methods=['POST'])
|
|
|
361 |
return jsonify({"similarity_score": similarity_score}), 200
|
362 |
|
363 |
except Exception as e:
|
364 |
+
return jsonify({"error": str(e)}), 500
|
|