Spaces:
Sleeping
Sleeping
original code
Browse files
app.py
CHANGED
|
@@ -10,11 +10,25 @@ from multilingual_pdf2text.models.document_model.document import Document
|
|
| 10 |
|
| 11 |
import pdfplumber
|
| 12 |
import docx2txt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
# --- Config ---
|
| 15 |
FLOWISE_URL = "https://siraflowappl.happywave-0e1819cd.uaenorth.azurecontainerapps.io/api/v1/prediction/5f2aa074-ae2e-4b06-a4a2-6f8dccbe59bb"
|
| 16 |
-
|
| 17 |
-
#
|
| 18 |
COUNTRIES = ["USA", "Germany", "UAE", "Turkey", "Jordan"]
|
| 19 |
LANGUAGES = ["English", "Arabic"]
|
| 20 |
|
|
@@ -78,7 +92,7 @@ def send_to_flowise(file, country: str, language: str) -> str:
|
|
| 78 |
return "⚠️ No content extracted from the uploaded file."
|
| 79 |
|
| 80 |
prompt = f"""Please audit the following employment contract in light of {country} labor law.
|
| 81 |
-
Only refer to the provided law document (do not use external knowledge)
|
| 82 |
Is the contract compliant? Provide reasoning and highlight any issues, and suggest improvements.
|
| 83 |
Be precise and don't miss any details in the contract.
|
| 84 |
Please respond in {language}.
|
|
|
|
| 10 |
|
| 11 |
import pdfplumber
|
| 12 |
import docx2txt
|
| 13 |
+
import shutil
|
| 14 |
+
import subprocess
|
| 15 |
+
|
| 16 |
+
print("🔍 Checking if Tesseract OCR is installed...")
|
| 17 |
+
|
| 18 |
+
tess_path = shutil.which("tesseract")
|
| 19 |
+
if tess_path:
|
| 20 |
+
print(f"✅ Tesseract found at: {tess_path}")
|
| 21 |
+
try:
|
| 22 |
+
version = subprocess.check_output(["tesseract", "--version"]).decode()
|
| 23 |
+
print(f"🧠 Tesseract version:\n{version}")
|
| 24 |
+
except Exception as e:
|
| 25 |
+
print(f"⚠️ Tesseract found but failed to run: {e}")
|
| 26 |
+
else:
|
| 27 |
+
print("❌ Tesseract not found. Arabic PDF extraction will likely fail.")
|
| 28 |
+
|
| 29 |
|
| 30 |
# --- Config ---
|
| 31 |
FLOWISE_URL = "https://siraflowappl.happywave-0e1819cd.uaenorth.azurecontainerapps.io/api/v1/prediction/5f2aa074-ae2e-4b06-a4a2-6f8dccbe59bb"
|
|
|
|
|
|
|
| 32 |
COUNTRIES = ["USA", "Germany", "UAE", "Turkey", "Jordan"]
|
| 33 |
LANGUAGES = ["English", "Arabic"]
|
| 34 |
|
|
|
|
| 92 |
return "⚠️ No content extracted from the uploaded file."
|
| 93 |
|
| 94 |
prompt = f"""Please audit the following employment contract in light of {country} labor law.
|
| 95 |
+
Only refer to the provided law document (do not use external knowledge), but you don't have to mention the exact source of info while answering.
|
| 96 |
Is the contract compliant? Provide reasoning and highlight any issues, and suggest improvements.
|
| 97 |
Be precise and don't miss any details in the contract.
|
| 98 |
Please respond in {language}.
|