Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- core/hf_inference.py +7 -11
- core/preview_generator.py +69 -2
core/hf_inference.py
CHANGED
|
@@ -335,17 +335,13 @@ class HFInferenceClient:
|
|
| 335 |
if not self.token:
|
| 336 |
raise ValueError("HF_TOKEN is required for inference")
|
| 337 |
|
| 338 |
-
#
|
| 339 |
-
#
|
| 340 |
-
#
|
| 341 |
-
#
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
except TypeError:
|
| 346 |
-
# Older huggingface_hub (<0.28) doesn't support provider param
|
| 347 |
-
self.sync_client = InferenceClient(token=self.token)
|
| 348 |
-
self.async_client = AsyncInferenceClient(token=self.token)
|
| 349 |
|
| 350 |
def get_model_for_agent(self, agent_name: str) -> str:
|
| 351 |
"""Get the appropriate model for an agent."""
|
|
|
|
| 335 |
if not self.token:
|
| 336 |
raise ValueError("HF_TOKEN is required for inference")
|
| 337 |
|
| 338 |
+
# Let huggingface_hub route to the best available provider automatically.
|
| 339 |
+
# Do NOT set base_url (overrides per-model routing) or
|
| 340 |
+
# provider="hf-inference" (that provider no longer hosts most models).
|
| 341 |
+
# The default provider="auto" picks the first available third-party
|
| 342 |
+
# provider (novita, together, cerebras, etc.) for each model.
|
| 343 |
+
self.sync_client = InferenceClient(token=self.token)
|
| 344 |
+
self.async_client = AsyncInferenceClient(token=self.token)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 345 |
|
| 346 |
def get_model_for_agent(self, agent_name: str) -> str:
|
| 347 |
"""Get the appropriate model for an agent."""
|
core/preview_generator.py
CHANGED
|
@@ -236,6 +236,16 @@ def generate_colors_asis_preview_html(
|
|
| 236 |
padding: 2px 6px;
|
| 237 |
border-radius: 4px;
|
| 238 |
}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
</style>
|
| 240 |
|
| 241 |
<div class="colors-asis-header">{count_info}</div>
|
|
@@ -315,6 +325,11 @@ def generate_spacing_asis_preview_html(
|
|
| 315 |
border-radius: 4px;
|
| 316 |
min-width: 4px;
|
| 317 |
}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 318 |
</style>
|
| 319 |
|
| 320 |
<div class="spacing-asis-preview">
|
|
@@ -384,6 +399,11 @@ def generate_radius_asis_preview_html(
|
|
| 384 |
color: #1a1a1a !important;
|
| 385 |
font-family: 'SF Mono', Monaco, monospace;
|
| 386 |
}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 387 |
</style>
|
| 388 |
|
| 389 |
<div class="radius-asis-preview">
|
|
@@ -468,6 +488,13 @@ def generate_shadows_asis_preview_html(
|
|
| 468 |
text-align: center;
|
| 469 |
word-break: break-all;
|
| 470 |
}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 471 |
</style>
|
| 472 |
|
| 473 |
<div class="shadows-asis-preview">
|
|
@@ -645,6 +672,18 @@ def generate_typography_preview_html(
|
|
| 645 |
.typography-preview tr:hover .preview-cell {{
|
| 646 |
background: #F5F5F5;
|
| 647 |
}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 648 |
</style>
|
| 649 |
|
| 650 |
<div class="typography-preview">
|
|
@@ -1081,6 +1120,15 @@ def generate_color_ramps_preview_html(
|
|
| 1081 |
border-radius: 6px;
|
| 1082 |
font-weight: 500;
|
| 1083 |
}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1084 |
</style>
|
| 1085 |
|
| 1086 |
<div class="color-ramps-preview">
|
|
@@ -1230,9 +1278,13 @@ def generate_semantic_color_ramps_html(
|
|
| 1230 |
# Handle empty analysis
|
| 1231 |
if not semantic_analysis:
|
| 1232 |
return '''
|
| 1233 |
-
<div style="padding: 40px; text-align: center; background: #fff3cd
|
| 1234 |
-
<p style="color: #856404
|
| 1235 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1236 |
'''
|
| 1237 |
|
| 1238 |
# Build sections
|
|
@@ -1427,6 +1479,21 @@ def generate_semantic_color_ramps_html(
|
|
| 1427 |
margin-bottom: 4px;
|
| 1428 |
font-size: 13px;
|
| 1429 |
}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1430 |
</style>
|
| 1431 |
|
| 1432 |
<div class="sem-ramps-preview">
|
|
|
|
| 236 |
padding: 2px 6px;
|
| 237 |
border-radius: 4px;
|
| 238 |
}}
|
| 239 |
+
|
| 240 |
+
/* Dark mode overrides */
|
| 241 |
+
.dark .colors-asis-header {{ color: #e2e8f0 !important; background: #1e293b !important; }}
|
| 242 |
+
.dark .colors-asis-preview {{ background: #0f172a !important; }}
|
| 243 |
+
.dark .color-row-asis {{ background: #1e293b !important; border-color: #475569 !important; }}
|
| 244 |
+
.dark .color-name-asis {{ color: #f1f5f9 !important; }}
|
| 245 |
+
.dark .frequency {{ color: #cbd5e1 !important; }}
|
| 246 |
+
.dark .context-badge {{ background: #334155 !important; color: #e2e8f0 !important; }}
|
| 247 |
+
.dark .aa-pass {{ color: #22c55e !important; background: #14532d !important; }}
|
| 248 |
+
.dark .aa-fail {{ color: #f87171 !important; background: #450a0a !important; }}
|
| 249 |
</style>
|
| 250 |
|
| 251 |
<div class="colors-asis-header">{count_info}</div>
|
|
|
|
| 325 |
border-radius: 4px;
|
| 326 |
min-width: 4px;
|
| 327 |
}}
|
| 328 |
+
|
| 329 |
+
/* Dark mode */
|
| 330 |
+
.dark .spacing-asis-preview {{ background: #0f172a !important; }}
|
| 331 |
+
.dark .spacing-row-asis {{ background: #1e293b !important; }}
|
| 332 |
+
.dark .spacing-label {{ color: #f1f5f9 !important; }}
|
| 333 |
</style>
|
| 334 |
|
| 335 |
<div class="spacing-asis-preview">
|
|
|
|
| 399 |
color: #1a1a1a !important;
|
| 400 |
font-family: 'SF Mono', Monaco, monospace;
|
| 401 |
}}
|
| 402 |
+
|
| 403 |
+
/* Dark mode */
|
| 404 |
+
.dark .radius-asis-preview {{ background: #0f172a !important; }}
|
| 405 |
+
.dark .radius-item {{ background: #1e293b !important; }}
|
| 406 |
+
.dark .radius-label {{ color: #f1f5f9 !important; }}
|
| 407 |
</style>
|
| 408 |
|
| 409 |
<div class="radius-asis-preview">
|
|
|
|
| 488 |
text-align: center;
|
| 489 |
word-break: break-all;
|
| 490 |
}}
|
| 491 |
+
|
| 492 |
+
/* Dark mode */
|
| 493 |
+
.dark .shadows-asis-preview {{ background: #0f172a !important; }}
|
| 494 |
+
.dark .shadow-item {{ background: #1e293b !important; }}
|
| 495 |
+
.dark .shadow-box {{ background: #334155 !important; }}
|
| 496 |
+
.dark .shadow-label {{ color: #f1f5f9 !important; }}
|
| 497 |
+
.dark .shadow-value {{ color: #94a3b8 !important; }}
|
| 498 |
</style>
|
| 499 |
|
| 500 |
<div class="shadows-asis-preview">
|
|
|
|
| 672 |
.typography-preview tr:hover .preview-cell {{
|
| 673 |
background: #F5F5F5;
|
| 674 |
}}
|
| 675 |
+
|
| 676 |
+
/* Dark mode */
|
| 677 |
+
.dark .typography-preview {{ background: #1e293b !important; }}
|
| 678 |
+
.dark .typography-preview th {{ background: #334155 !important; color: #e2e8f0 !important; border-bottom-color: #475569 !important; }}
|
| 679 |
+
.dark .typography-preview td {{ color: #e2e8f0 !important; }}
|
| 680 |
+
.dark .typography-preview .meta-row {{ background: #1e293b !important; border-top-color: #334155 !important; }}
|
| 681 |
+
.dark .typography-preview .scale-name,
|
| 682 |
+
.dark .typography-preview .scale-label {{ color: #f1f5f9 !important; background: #475569 !important; }}
|
| 683 |
+
.dark .typography-preview .meta {{ color: #cbd5e1 !important; }}
|
| 684 |
+
.dark .typography-preview .preview-cell {{ background: #0f172a !important; border-bottom-color: #334155 !important; }}
|
| 685 |
+
.dark .typography-preview .preview-text {{ color: #f1f5f9 !important; }}
|
| 686 |
+
.dark .typography-preview tr:hover .preview-cell {{ background: #1e293b !important; }}
|
| 687 |
</style>
|
| 688 |
|
| 689 |
<div class="typography-preview">
|
|
|
|
| 1120 |
border-radius: 6px;
|
| 1121 |
font-weight: 500;
|
| 1122 |
}}
|
| 1123 |
+
|
| 1124 |
+
/* Dark mode */
|
| 1125 |
+
.dark .color-ramps-preview {{ background: #0f172a !important; }}
|
| 1126 |
+
.dark .ramps-header-info {{ color: #e2e8f0 !important; background: #1e293b !important; }}
|
| 1127 |
+
.dark .ramp-header {{ background: #1e293b !important; }}
|
| 1128 |
+
.dark .ramp-header-label {{ color: #cbd5e1 !important; }}
|
| 1129 |
+
.dark .color-row {{ background: #1e293b !important; border-color: #475569 !important; }}
|
| 1130 |
+
.dark .color-name {{ color: #f1f5f9 !important; background: #475569 !important; }}
|
| 1131 |
+
.dark .color-hex {{ color: #cbd5e1 !important; }}
|
| 1132 |
</style>
|
| 1133 |
|
| 1134 |
<div class="color-ramps-preview">
|
|
|
|
| 1278 |
# Handle empty analysis
|
| 1279 |
if not semantic_analysis:
|
| 1280 |
return '''
|
| 1281 |
+
<div class="sem-warning-box" style="padding: 40px; text-align: center; background: #fff3cd; border-radius: 8px;">
|
| 1282 |
+
<p style="color: #856404; font-size: 14px;">⚠️ No semantic analysis available.</p>
|
| 1283 |
</div>
|
| 1284 |
+
<style>
|
| 1285 |
+
.dark .sem-warning-box { background: #422006 !important; border-color: #b45309 !important; }
|
| 1286 |
+
.dark .sem-warning-box p { color: #fde68a !important; }
|
| 1287 |
+
</style>
|
| 1288 |
'''
|
| 1289 |
|
| 1290 |
# Build sections
|
|
|
|
| 1479 |
margin-bottom: 4px;
|
| 1480 |
font-size: 13px;
|
| 1481 |
}}
|
| 1482 |
+
|
| 1483 |
+
/* Dark mode */
|
| 1484 |
+
.dark .sem-ramps-preview {{ background: #0f172a !important; }}
|
| 1485 |
+
.dark .sem-category {{ background: #1e293b !important; border-color: #475569 !important; }}
|
| 1486 |
+
.dark .sem-cat-title {{ color: #f1f5f9 !important; border-bottom-color: #475569 !important; }}
|
| 1487 |
+
.dark .sem-color-row {{ background: #0f172a !important; border-color: #334155 !important; }}
|
| 1488 |
+
.dark .sem-role {{ color: #f1f5f9 !important; }}
|
| 1489 |
+
.dark .sem-hex {{ color: #cbd5e1 !important; }}
|
| 1490 |
+
.dark .llm-rec {{ background: #422006 !important; border-color: #b45309 !important; }}
|
| 1491 |
+
.dark .rec-label {{ color: #fbbf24 !important; }}
|
| 1492 |
+
.dark .rec-issue {{ color: #fde68a !important; }}
|
| 1493 |
+
.dark .rec-arrow {{ color: #fbbf24 !important; }}
|
| 1494 |
+
.dark .llm-summary {{ background: #1e3a5f !important; border-color: #3b82f6 !important; }}
|
| 1495 |
+
.dark .llm-summary h4 {{ color: #93c5fd !important; }}
|
| 1496 |
+
.dark .llm-summary ul, .dark .llm-summary li {{ color: #bfdbfe !important; }}
|
| 1497 |
</style>
|
| 1498 |
|
| 1499 |
<div class="sem-ramps-preview">
|