RSHVR commited on
Commit
4df3cab
·
verified ·
1 Parent(s): 346ad0c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -1
app.py CHANGED
@@ -441,7 +441,51 @@ async def extract_product_data(request: ProductURLRequest):
441
 
442
  if request.format == "markdown":
443
  # Add markdown formatting (implementation from smolagent_api.py)
444
- # ...add markdown formatting function here...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
445
  result["markdown"] = format_as_markdown(result)
446
 
447
  return {
 
441
 
442
  if request.format == "markdown":
443
  # Add markdown formatting (implementation from smolagent_api.py)
444
+ def format_as_markdown(data: Dict[str, Any]) -> str:
445
+ """Convert the extracted data to markdown format for nicer display"""
446
+ result = []
447
+
448
+ # Add request ID
449
+ result.append(f"### Request ID: {data.get('request_id', 'N/A')}")
450
+ result.append("")
451
+
452
+ # Add images section
453
+ result.append("### Images")
454
+ images = data.get("images", {})
455
+ if images:
456
+ for img_id, img_info in images.items():
457
+ result.append(f"- **ID**: {img_id}")
458
+ result.append(f" - **URL**: {img_info.get('url', 'N/A')}")
459
+ result.append(f" - **Type**: {img_info.get('type', 'unknown')}")
460
+ result.append(f" - **Alt**: {img_info.get('alt', 'N/A')}")
461
+ result.append("")
462
+ else:
463
+ result.append("No images found.")
464
+ result.append("")
465
+
466
+ # Add measurements section
467
+ result.append("### Measurements")
468
+ measurements = data.get("measurements", {})
469
+ if measurements:
470
+ for key, value in measurements.items():
471
+ result.append(f"- **{key.title()}**: {value}")
472
+ result.append("")
473
+ else:
474
+ result.append("No measurements found.")
475
+ result.append("")
476
+
477
+ # Add materials section
478
+ result.append("### Materials")
479
+ materials = data.get("materials", {})
480
+ if materials:
481
+ for key, value in materials.items():
482
+ result.append(f"- **{key.title()}**: {value}")
483
+ result.append("")
484
+ else:
485
+ result.append("No materials information found.")
486
+ result.append("")
487
+
488
+ return "\n".join(result)
489
  result["markdown"] = format_as_markdown(result)
490
 
491
  return {