Spaces:
Sleeping
Sleeping
Upload semantic_analyzer.py
Browse files- agents/semantic_analyzer.py +28 -4
agents/semantic_analyzer.py
CHANGED
|
@@ -629,11 +629,15 @@ def generate_semantic_preview_html(analysis_result: dict) -> str:
|
|
| 629 |
# Handle empty or invalid result
|
| 630 |
if not analysis_result:
|
| 631 |
return '''
|
| 632 |
-
<div style="padding: 40px; text-align: center; background: #fff3cd
|
| 633 |
-
<p style="color: #856404
|
| 634 |
⚠️ Semantic analysis did not produce results. Check the logs for errors.
|
| 635 |
</p>
|
| 636 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 637 |
'''
|
| 638 |
|
| 639 |
def color_card(hex_val: str, role: str, confidence: str, reason: str = "") -> str:
|
|
@@ -704,11 +708,15 @@ def generate_semantic_preview_html(analysis_result: dict) -> str:
|
|
| 704 |
# Check if any sections were created
|
| 705 |
if not sections_html.strip():
|
| 706 |
return '''
|
| 707 |
-
<div style="padding: 40px; text-align: center; background: #fff3cd
|
| 708 |
-
<p style="color: #856404
|
| 709 |
⚠️ No semantic color categories were detected. The colors may not have enough context data (elements, CSS properties) for classification.
|
| 710 |
</p>
|
| 711 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 712 |
'''
|
| 713 |
|
| 714 |
# Summary
|
|
@@ -866,6 +874,22 @@ def generate_semantic_preview_html(analysis_result: dict) -> str:
|
|
| 866 |
color: #555 !important;
|
| 867 |
margin-top: 4px;
|
| 868 |
}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 869 |
</style>
|
| 870 |
|
| 871 |
<div class="sem-preview">
|
|
|
|
| 629 |
# Handle empty or invalid result
|
| 630 |
if not analysis_result:
|
| 631 |
return '''
|
| 632 |
+
<div class="sem-warning-box" style="padding: 40px; text-align: center; background: #fff3cd; border-radius: 8px; border: 1px solid #ffc107;">
|
| 633 |
+
<p style="color: #856404; font-size: 14px; margin: 0;">
|
| 634 |
⚠️ Semantic analysis did not produce results. Check the logs for errors.
|
| 635 |
</p>
|
| 636 |
</div>
|
| 637 |
+
<style>
|
| 638 |
+
.dark .sem-warning-box { background: #422006 !important; border-color: #b45309 !important; }
|
| 639 |
+
.dark .sem-warning-box p { color: #fde68a !important; }
|
| 640 |
+
</style>
|
| 641 |
'''
|
| 642 |
|
| 643 |
def color_card(hex_val: str, role: str, confidence: str, reason: str = "") -> str:
|
|
|
|
| 708 |
# Check if any sections were created
|
| 709 |
if not sections_html.strip():
|
| 710 |
return '''
|
| 711 |
+
<div class="sem-warning-box" style="padding: 40px; text-align: center; background: #fff3cd; border-radius: 8px; border: 1px solid #ffc107;">
|
| 712 |
+
<p style="color: #856404; font-size: 14px; margin: 0;">
|
| 713 |
⚠️ No semantic color categories were detected. The colors may not have enough context data (elements, CSS properties) for classification.
|
| 714 |
</p>
|
| 715 |
</div>
|
| 716 |
+
<style>
|
| 717 |
+
.dark .sem-warning-box { background: #422006 !important; border-color: #b45309 !important; }
|
| 718 |
+
.dark .sem-warning-box p { color: #fde68a !important; }
|
| 719 |
+
</style>
|
| 720 |
'''
|
| 721 |
|
| 722 |
# Summary
|
|
|
|
| 874 |
color: #555 !important;
|
| 875 |
margin-top: 4px;
|
| 876 |
}}
|
| 877 |
+
|
| 878 |
+
/* Dark mode */
|
| 879 |
+
.dark .sem-preview {{ background: #0f172a !important; }}
|
| 880 |
+
.dark .sem-category-section {{ background: #1e293b !important; border-color: #475569 !important; }}
|
| 881 |
+
.dark .sem-category-title {{ color: #f1f5f9 !important; border-bottom-color: #475569 !important; }}
|
| 882 |
+
.dark .sem-color-card {{ background: #334155 !important; border-color: #475569 !important; }}
|
| 883 |
+
.dark .sem-color-details {{ background: #1e293b !important; }}
|
| 884 |
+
.dark .sem-role-name {{ color: #f1f5f9 !important; }}
|
| 885 |
+
.dark .sem-preview .confidence.high {{ background: #14532d !important; color: #86efac !important; }}
|
| 886 |
+
.dark .sem-preview .confidence.medium {{ background: #422006 !important; color: #fde68a !important; }}
|
| 887 |
+
.dark .sem-preview .confidence.low {{ background: #450a0a !important; color: #fca5a5 !important; }}
|
| 888 |
+
.dark .sem-summary-section {{ background: #1e293b !important; border-color: #475569 !important; }}
|
| 889 |
+
.dark .sem-summary-title {{ color: #f1f5f9 !important; }}
|
| 890 |
+
.dark .sem-stat {{ background: #334155 !important; }}
|
| 891 |
+
.dark .sem-stat-value {{ color: #f1f5f9 !important; }}
|
| 892 |
+
.dark .sem-stat-label {{ color: #94a3b8 !important; }}
|
| 893 |
</style>
|
| 894 |
|
| 895 |
<div class="sem-preview">
|