Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -227,14 +227,15 @@ def extract_with_gemini(processed_data: Dict[str, Any], api_key: str, model_name
|
|
| 227 |
}
|
| 228 |
|
| 229 |
|
| 230 |
-
def process_documents(files
|
| 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"
|
|
@@ -293,20 +294,6 @@ def create_interface():
|
|
| 293 |
|
| 294 |
with gr.Row():
|
| 295 |
with gr.Column(scale=2):
|
| 296 |
-
api_key_input = gr.Textbox(
|
| 297 |
-
label="π Gemini API Key",
|
| 298 |
-
placeholder="Enter your Google Gemini API key (AIza...)",
|
| 299 |
-
type="password",
|
| 300 |
-
info="Get your key from https://aistudio.google.com/apikey"
|
| 301 |
-
)
|
| 302 |
-
|
| 303 |
-
model_choice = gr.Dropdown(
|
| 304 |
-
choices=["gemini-2.0-flash-exp", "gemini-1.5-pro", "gemini-1.5-flash"],
|
| 305 |
-
value="gemini-2.0-flash-exp",
|
| 306 |
-
label="Model Selection",
|
| 307 |
-
info="Latest model recommended for best results"
|
| 308 |
-
)
|
| 309 |
-
|
| 310 |
file_input = gr.File(
|
| 311 |
label="π Upload Documents",
|
| 312 |
file_count="multiple",
|
|
@@ -345,18 +332,18 @@ def create_interface():
|
|
| 345 |
# Button action
|
| 346 |
submit_btn.click(
|
| 347 |
fn=process_documents,
|
| 348 |
-
inputs=[file_input
|
| 349 |
outputs=[status_output, json_output, display_output]
|
| 350 |
)
|
| 351 |
|
| 352 |
# Examples
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
|
| 361 |
return demo
|
| 362 |
|
|
|
|
| 227 |
}
|
| 228 |
|
| 229 |
|
| 230 |
+
def process_documents(files):
|
| 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 and default model
|
| 237 |
api_key = GEMINI_API_KEY
|
| 238 |
+
model_choice = "gemini-2.0-flash-exp"
|
| 239 |
|
| 240 |
if not api_key or api_key.strip() == "":
|
| 241 |
return "β Error: API key not configured in code", "{}", "API key missing"
|
|
|
|
| 294 |
|
| 295 |
with gr.Row():
|
| 296 |
with gr.Column(scale=2):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 297 |
file_input = gr.File(
|
| 298 |
label="π Upload Documents",
|
| 299 |
file_count="multiple",
|
|
|
|
| 332 |
# Button action
|
| 333 |
submit_btn.click(
|
| 334 |
fn=process_documents,
|
| 335 |
+
inputs=[file_input],
|
| 336 |
outputs=[status_output, json_output, display_output]
|
| 337 |
)
|
| 338 |
|
| 339 |
# Examples
|
| 340 |
+
gr.Examples(
|
| 341 |
+
examples=[
|
| 342 |
+
[["example1.pdf"]],
|
| 343 |
+
],
|
| 344 |
+
inputs=[file_input],
|
| 345 |
+
label="Example Usage"
|
| 346 |
+
)
|
| 347 |
|
| 348 |
return demo
|
| 349 |
|