Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,6 +9,11 @@ import PyPDF2
|
|
| 9 |
import tempfile
|
| 10 |
import traceback
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
# ==============================================================
|
| 13 |
# Enhanced extraction prompt with better instructions
|
| 14 |
# ==============================================================
|
|
@@ -222,14 +227,17 @@ def extract_with_gemini(processed_data: Dict[str, Any], api_key: str, model_name
|
|
| 222 |
}
|
| 223 |
|
| 224 |
|
| 225 |
-
def process_documents(files,
|
| 226 |
"""Main Gradio processing function"""
|
| 227 |
|
| 228 |
if not files or len(files) == 0:
|
| 229 |
return "❌ Error: Please upload at least one file", "{}", "No files provided"
|
| 230 |
|
|
|
|
|
|
|
|
|
|
| 231 |
if not api_key or api_key.strip() == "":
|
| 232 |
-
return "❌ Error:
|
| 233 |
|
| 234 |
try:
|
| 235 |
# Get file paths
|
|
|
|
| 9 |
import tempfile
|
| 10 |
import traceback
|
| 11 |
|
| 12 |
+
# ==============================================================
|
| 13 |
+
# API Configuration - Add your key here
|
| 14 |
+
# ==============================================================
|
| 15 |
+
GEMINI_API_KEY = "AIzaSyB2b80YwNHs3Yj6RZOTL8wjXk2YhxCluOA" # Replace with your key
|
| 16 |
+
|
| 17 |
# ==============================================================
|
| 18 |
# Enhanced extraction prompt with better instructions
|
| 19 |
# ==============================================================
|
|
|
|
| 227 |
}
|
| 228 |
|
| 229 |
|
| 230 |
+
def process_documents(files, model_choice):
|
| 231 |
"""Main Gradio processing function"""
|
| 232 |
|
| 233 |
if not files or len(files) == 0:
|
| 234 |
return "❌ Error: Please upload at least one file", "{}", "No files provided"
|
| 235 |
|
| 236 |
+
# Use the hardcoded API key
|
| 237 |
+
api_key = GEMINI_API_KEY
|
| 238 |
+
|
| 239 |
if not api_key or api_key.strip() == "":
|
| 240 |
+
return "❌ Error: API key not configured in code", "{}", "API key missing"
|
| 241 |
|
| 242 |
try:
|
| 243 |
# Get file paths
|