Spaces:
Sleeping
Sleeping
Update app.py
Browse files297 unmodified lines298299300301302303297 unmodified linesprint(e)return jsonify({"error": str(list)}), 500# Route to get text description embeddings@cache.cached(timeout=300)@app.route('/getTextDescriptionEmbedding', methods=['POST'])297 unmodified lines298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455297 unmodified linesprint(e)return jsonify({"error": str(list)}), 500@cache.cached(timeout=300)@app.route('/extract_pdf_text_and_embedding1', methods=['POST'])def extract_pdf_text_and_embedding():list = []try:list.append(1)pdf_url = request.json.get("pdfUrl")list.append(2)print(1)return jsonify({"content":str(list)}) , 200# pages_info = "Error"# try :# pages_info = seperate_image_text_from_pdf(pdf_url)# except Exception as e:# print(e)# return jsonify({"error": "Failed to fetch the PDF from the URL"}), 500# list.append(3)# if(pages_info == "Error"):# return jsonify({"error": "Failed to fetch the PDF from the URL seperate_image_text_from_pdf "}), 500# list.append(4)# content = pdf_image_text_embedding_and_text_embedding(pages_info)# if content == "Error":# return jsonify({"error": "An error occurred while processing the PDF"}), 500# list.append(5)# print(content)# return jsonify({"content": content}), 200except Exception as e:print(e)return jsonify({"error": str(list)}), 500@cache.cached(timeout=300)@app.route('/extract_pdf_text_and_embedding2', methods=['POST'])def extract_pdf_text_and_embedding():list = []try:list.append(1)pdf_url = request.json.get("pdfUrl")list.append(2)print(1)return jsonify({"content":str(list)}) , 200pages_info = "Error"try :pages_info = seperate_image_text_from_pdf(pdf_url)except Exception as e:return jsonify({"content":str(list)}) , 200# list.append(3)# if(pages_info == "Error"):# return jsonify({"error": "Failed to fetch the PDF from the URL seperate_image_text_from_pdf "}), 500# list.append(4)# content = pdf_image_text_embedding_and_text_embedding(pages_info)# if content == "Error":# return jsonify({"error": "An error occurred while processing the PDF"}), 500# list.append(5)# print(content)# return jsonify({"content": content}), 200except Exception as e:print(e)return jsonify({"error": str(list)}), 500@cache.cached(timeout=300)@app.route('/extract_pdf_text_and_embedding3', methods=['POST'])def extract_pdf_text_and_embedding():list = []try:list.append(1)pdf_url = request.json.get("pdfUrl")list.append(2)print(1)return jsonify({"content":str(list)}) , 200pages_info = "Error"try :pages_info = seperate_image_text_from_pdf(pdf_url)except Exception as e:return jsonify({"content":str(list)}) , 200list.append(3)if(pages_info == "Error"):return jsonify({"content":str(list)}) , 200# list.append(4)# content = pdf_image_text_embedding_and_text_embedding(pages_info)# if content == "Error":# return jsonify({"error": "An error occurred while processing the PDF"}), 500# list.append(5)# print(content)# return jsonify({"content": content}), 200except Exception as e:print(e)return jsonify({"error": str(list)}), 500@cache.cached(timeout=300)@app.route('/extract_pdf_text_and_embedding4', methods=['POST'])def extract_pdf_text_and_embedding():list = []try:list.append(1)pdf_url = request.json.get("pdfUrl")list.append(2)print(1)return jsonify({"content":str(list)}) , 200pages_info = "Error"try :pages_info = seperate_image_text_from_pdf(pdf_url)except Exception as e:return jsonify({"content":str(list)}) , 200list.append(3)if(pages_info == "Error"):return jsonify({"content":str(list)}) , 200list.append(4)content = pdf_image_text_embedding_and_text_embedding(pages_info)if content == "Error":return jsonify({"content":str(list)}) , 200# list.append(5)# print(content)# return jsonify({"content": content}), 200except Exception as e:print(e)return jsonify({"error": str(list)}), 500@cache.cached(timeout=300)@app.route('/extract_pdf_text_and_embedding5', methods=['POST'])def extract_pdf_text_and_embedding():list = []try:list.append(1)pdf_url = request.json.get("pdfUrl")list.append(2)print(1)return jsonify({"content":str(list)}) , 200pages_info = "Error"try :pages_info = seperate_image_text_from_pdf(pdf_url)except Exception as e:return jsonify({"content":str(list)}) , 200list.append(3)if(pages_info == "Error"):return jsonify({"content":str(list)}) , 200list.append(4)content = pdf_image_text_embedding_and_text_embedding(pages_info)if content == "Error":return jsonify({"content":str(list)}) , 200list.append(5)print(content)return jsonify({"content": content}), 200except Exception as e:print(e)return jsonify({"error": str(list)}), 500# Route to get text description embeddings@cache.cached(timeout=300)@app.route('/getTextDescriptionEmbedding', methods=['POST'])
app.py+152