Spaces:
Sleeping
Demote non-LLM scene picker; AI topic preview is now the primary CTA
Browse filesThe two-button row read as "pick one of two equivalent paths" but
they aren't — the AI path produces meaningfully better study guides
when an API key is available. Promote the topic-preview button to
the primary CTA the moment a key arrives, and demote the plain
"Preview scenes" button to a small text-link beneath it ("or pick
slides individually without AI"). When no key is present, hide the
AI button entirely and let the plain picker stand alone as the
primary CTA — no dead "disabled because key missing" state.
The non-LLM path stays fully functional and intentionally one click
away, so users on the public Space without a key still get the
demo; users worried about privacy / cost / outages keep their
escape hatch; the CLI is unaffected.
Backend: /jobs now rejects up-front when any AI toggle is ticked
without an API key. Previously per-segment toggles silently no-op'd
and topic segmentation hard-failed halfway through; now the user
gets a single explicit "add a key or uncheck AI features" 400
before any work starts.
- app/main.py +17 -0
- app/templates/index.html +61 -40
|
@@ -573,6 +573,23 @@ async def start_job(
|
|
| 573 |
if transcript_suffix not in TRANSCRIPT_SUFFIXES:
|
| 574 |
raise HTTPException(400, f"Unsupported transcript format: {transcript_suffix or '(none)'}")
|
| 575 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 576 |
# Resolve preview cache entry (if the user went through either
|
| 577 |
# scene picker — the basic Preview scenes or the topic-aware twin).
|
| 578 |
preview_entry: dict | None = None
|
|
|
|
| 573 |
if transcript_suffix not in TRANSCRIPT_SUFFIXES:
|
| 574 |
raise HTTPException(400, f"Unsupported transcript format: {transcript_suffix or '(none)'}")
|
| 575 |
|
| 576 |
+
# If the user ticked any AI feature but provided no API key, the run
|
| 577 |
+
# would either silently no-op (per-segment toggles) or hard-fail
|
| 578 |
+
# halfway through (topic segmentation). Catch it up-front with a
|
| 579 |
+
# message that names the fix, so the form doesn't appear to "work"
|
| 580 |
+
# while quietly dropping every LLM-driven feature they wanted.
|
| 581 |
+
any_llm_requested = (
|
| 582 |
+
llm_alt_text or llm_key_terms or llm_math_equations
|
| 583 |
+
or llm_section_title or llm_ocr_text or llm_topic_segmentation
|
| 584 |
+
)
|
| 585 |
+
if any_llm_requested and not (anthropic_api_key and anthropic_api_key.strip()):
|
| 586 |
+
raise HTTPException(
|
| 587 |
+
400,
|
| 588 |
+
"AI features were requested (e.g. topic segmentation, section titles) "
|
| 589 |
+
"but no Anthropic API key was provided. Either add a key in the AI "
|
| 590 |
+
"assist section or uncheck the AI features.",
|
| 591 |
+
)
|
| 592 |
+
|
| 593 |
# Resolve preview cache entry (if the user went through either
|
| 594 |
# scene picker — the basic Preview scenes or the topic-aware twin).
|
| 595 |
preview_entry: dict | None = None
|
|
@@ -415,18 +415,47 @@
|
|
| 415 |
.vgm-preview-btn:hover:not(:disabled) { background: var(--color-primary-dark); }
|
| 416 |
.vgm-preview-btn:active:not(:disabled) { transform: translateY(1px); }
|
| 417 |
.vgm-preview-btn:disabled { opacity: 0.45; cursor: not-allowed; }
|
| 418 |
-
.vgm-preview-
|
| 419 |
display: flex;
|
| 420 |
-
flex-
|
| 421 |
-
|
|
|
|
| 422 |
margin-top: 0.5rem;
|
| 423 |
}
|
| 424 |
-
.vgm-preview-
|
| 425 |
margin-top: 0;
|
| 426 |
display: inline-flex;
|
| 427 |
align-items: center;
|
| 428 |
gap: 0.45rem;
|
| 429 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 430 |
.vgm-preview-btn__icon {
|
| 431 |
width: 1.05rem;
|
| 432 |
height: 1.05rem;
|
|
@@ -445,22 +474,6 @@
|
|
| 445 |
color: #fff;
|
| 446 |
vertical-align: 0.05em;
|
| 447 |
}
|
| 448 |
-
.vgm-preview-btn--alt .vgm-btn-badge {
|
| 449 |
-
background: var(--color-primary);
|
| 450 |
-
color: #fff;
|
| 451 |
-
}
|
| 452 |
-
/* Twin button for the LLM-driven topic-scene preview. Same shape
|
| 453 |
-
as the primary preview button but outlined so the user can tell
|
| 454 |
-
the two CTAs apart at a glance. */
|
| 455 |
-
.vgm-preview-btn--alt {
|
| 456 |
-
background: var(--color-surface);
|
| 457 |
-
color: var(--color-primary);
|
| 458 |
-
border: 1.5px solid var(--color-primary);
|
| 459 |
-
}
|
| 460 |
-
.vgm-preview-btn--alt:hover:not(:disabled) {
|
| 461 |
-
background: var(--color-primary-soft);
|
| 462 |
-
color: var(--color-primary-dark);
|
| 463 |
-
}
|
| 464 |
/* Topic preview cards carry a title and summary, so each card is
|
| 465 |
wider than a plain scene thumbnail and stacks the metadata below
|
| 466 |
the image. */
|
|
@@ -881,16 +894,10 @@
|
|
| 881 |
</div>
|
| 882 |
|
| 883 |
<div class="vgm-field vgm-field--preview">
|
| 884 |
-
<div class="vgm-preview-
|
| 885 |
-
<
|
| 886 |
-
|
| 887 |
-
|
| 888 |
-
<line x1="6" y1="4" x2="6" y2="16" stroke="currentColor" stroke-width="1.2"/>
|
| 889 |
-
<line x1="14" y1="4" x2="14" y2="16" stroke="currentColor" stroke-width="1.2"/>
|
| 890 |
-
</svg>
|
| 891 |
-
<span>Preview scenes</span>
|
| 892 |
-
</button>
|
| 893 |
-
<button type="button" id="topic-preview-btn" class="vgm-preview-btn vgm-preview-btn--alt" disabled>
|
| 894 |
<svg class="vgm-preview-btn__icon" viewBox="0 0 20 20" aria-hidden="true" focusable="false">
|
| 895 |
<path d="M10 2 L11.5 6.5 L16 8 L11.5 9.5 L10 14 L8.5 9.5 L4 8 L8.5 6.5 Z"
|
| 896 |
fill="currentColor"/>
|
|
@@ -900,6 +907,18 @@
|
|
| 900 |
<span>Preview topic scenes</span>
|
| 901 |
<span class="vgm-btn-badge">AI</span>
|
| 902 |
</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 903 |
</div>
|
| 904 |
<p class="vgm-preview-hint">Tip: preview first so you only generate the slides you'll keep.</p>
|
| 905 |
<p class="vgm-preview-missing" id="preview-missing" aria-live="polite"></p>
|
|
@@ -1318,28 +1337,30 @@
|
|
| 1318 |
const transcriptInput = form.querySelector('#transcript');
|
| 1319 |
const apiKeyInput = form.querySelector('#anthropic_api_key');
|
| 1320 |
const previewMissing = document.getElementById('preview-missing');
|
|
|
|
| 1321 |
|
| 1322 |
function updatePreviewButtons() {
|
| 1323 |
const hasVideo = !!(videoInput.files && videoInput.files[0]);
|
| 1324 |
const hasTranscript = !!(transcriptInput && transcriptInput.files && transcriptInput.files[0]);
|
| 1325 |
const hasKey = !!(apiKeyInput && apiKeyInput.value.trim());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1326 |
previewBtn.disabled = !hasVideo;
|
| 1327 |
topicPreviewBtn.disabled = !(hasVideo && hasTranscript && hasKey);
|
| 1328 |
// Surface the exact missing input(s) so the user doesn't have to
|
| 1329 |
// hunt around for why the button is greyed out. Empty string
|
| 1330 |
// hides the line entirely via the :empty CSS rule.
|
| 1331 |
if (previewMissing) {
|
| 1332 |
-
const missing = [];
|
| 1333 |
-
if (!hasVideo) missing.push('a video');
|
| 1334 |
-
if (!hasTranscript) missing.push('a transcript');
|
| 1335 |
-
if (!hasKey) missing.push('an Anthropic API key');
|
| 1336 |
if (!hasVideo) {
|
| 1337 |
-
previewMissing.textContent =
|
| 1338 |
-
} else if (
|
| 1339 |
-
//
|
| 1340 |
-
|
| 1341 |
-
previewMissing.textContent =
|
| 1342 |
-
`Topic preview needs ${missing.join(' and ')}.`;
|
| 1343 |
} else {
|
| 1344 |
previewMissing.textContent = '';
|
| 1345 |
}
|
|
|
|
| 415 |
.vgm-preview-btn:hover:not(:disabled) { background: var(--color-primary-dark); }
|
| 416 |
.vgm-preview-btn:active:not(:disabled) { transform: translateY(1px); }
|
| 417 |
.vgm-preview-btn:disabled { opacity: 0.45; cursor: not-allowed; }
|
| 418 |
+
.vgm-preview-actions {
|
| 419 |
display: flex;
|
| 420 |
+
flex-direction: column;
|
| 421 |
+
align-items: flex-start;
|
| 422 |
+
gap: 0.4rem;
|
| 423 |
margin-top: 0.5rem;
|
| 424 |
}
|
| 425 |
+
.vgm-preview-actions .vgm-preview-btn {
|
| 426 |
margin-top: 0;
|
| 427 |
display: inline-flex;
|
| 428 |
align-items: center;
|
| 429 |
gap: 0.45rem;
|
| 430 |
}
|
| 431 |
+
/* Two display modes — toggled via data-mode on .vgm-preview-actions.
|
| 432 |
+
no-key: AI button hidden, plain scene picker is the primary CTA.
|
| 433 |
+
with-key: AI button is the primary CTA; plain picker demotes to a
|
| 434 |
+
small text-link beneath it. */
|
| 435 |
+
.vgm-preview-actions[data-mode="no-key"] #topic-preview-btn { display: none; }
|
| 436 |
+
.vgm-preview-actions[data-mode="no-key"] #preview-btn .vgm-preview-btn__label--demoted { display: none; }
|
| 437 |
+
.vgm-preview-actions[data-mode="with-key"] #preview-btn .vgm-preview-btn__label--full { display: none; }
|
| 438 |
+
/* Demoted "or pick slides individually" link styling. Same DOM
|
| 439 |
+
element (so the click handler stays attached), restyled to read
|
| 440 |
+
as a quiet secondary action under the primary AI button. */
|
| 441 |
+
.vgm-preview-actions[data-mode="with-key"] #preview-btn {
|
| 442 |
+
background: transparent;
|
| 443 |
+
color: var(--color-text-muted);
|
| 444 |
+
border: 0;
|
| 445 |
+
padding: 0.25rem 0.1rem;
|
| 446 |
+
box-shadow: none;
|
| 447 |
+
font-size: 0.82rem;
|
| 448 |
+
font-weight: 500;
|
| 449 |
+
text-decoration: underline;
|
| 450 |
+
text-underline-offset: 0.18em;
|
| 451 |
+
}
|
| 452 |
+
.vgm-preview-actions[data-mode="with-key"] #preview-btn:hover:not(:disabled) {
|
| 453 |
+
color: var(--color-primary);
|
| 454 |
+
background: transparent;
|
| 455 |
+
}
|
| 456 |
+
.vgm-preview-actions[data-mode="with-key"] #preview-btn .vgm-preview-btn__icon {
|
| 457 |
+
opacity: 0.7;
|
| 458 |
+
}
|
| 459 |
.vgm-preview-btn__icon {
|
| 460 |
width: 1.05rem;
|
| 461 |
height: 1.05rem;
|
|
|
|
| 474 |
color: #fff;
|
| 475 |
vertical-align: 0.05em;
|
| 476 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 477 |
/* Topic preview cards carry a title and summary, so each card is
|
| 478 |
wider than a plain scene thumbnail and stacks the metadata below
|
| 479 |
the image. */
|
|
|
|
| 894 |
</div>
|
| 895 |
|
| 896 |
<div class="vgm-field vgm-field--preview">
|
| 897 |
+
<div class="vgm-preview-actions" id="preview-actions" data-mode="no-key">
|
| 898 |
+
<!-- Topic preview (AI). Promoted to primary CTA when an API
|
| 899 |
+
key is present; hidden when not. -->
|
| 900 |
+
<button type="button" id="topic-preview-btn" class="vgm-preview-btn vgm-preview-btn--primary" disabled>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 901 |
<svg class="vgm-preview-btn__icon" viewBox="0 0 20 20" aria-hidden="true" focusable="false">
|
| 902 |
<path d="M10 2 L11.5 6.5 L16 8 L11.5 9.5 L10 14 L8.5 9.5 L4 8 L8.5 6.5 Z"
|
| 903 |
fill="currentColor"/>
|
|
|
|
| 907 |
<span>Preview topic scenes</span>
|
| 908 |
<span class="vgm-btn-badge">AI</span>
|
| 909 |
</button>
|
| 910 |
+
<!-- Plain scene picker (no AI). Becomes the primary CTA
|
| 911 |
+
when no API key is set; demotes to a small text link
|
| 912 |
+
beneath the topic button when a key is set. -->
|
| 913 |
+
<button type="button" id="preview-btn" class="vgm-preview-btn vgm-preview-btn--primary" disabled>
|
| 914 |
+
<svg class="vgm-preview-btn__icon" viewBox="0 0 20 20" aria-hidden="true" focusable="false">
|
| 915 |
+
<rect x="2" y="4" width="16" height="12" rx="1.5" fill="none" stroke="currentColor" stroke-width="1.6"/>
|
| 916 |
+
<line x1="6" y1="4" x2="6" y2="16" stroke="currentColor" stroke-width="1.2"/>
|
| 917 |
+
<line x1="14" y1="4" x2="14" y2="16" stroke="currentColor" stroke-width="1.2"/>
|
| 918 |
+
</svg>
|
| 919 |
+
<span class="vgm-preview-btn__label--full">Preview scenes</span>
|
| 920 |
+
<span class="vgm-preview-btn__label--demoted">or pick slides individually without AI</span>
|
| 921 |
+
</button>
|
| 922 |
</div>
|
| 923 |
<p class="vgm-preview-hint">Tip: preview first so you only generate the slides you'll keep.</p>
|
| 924 |
<p class="vgm-preview-missing" id="preview-missing" aria-live="polite"></p>
|
|
|
|
| 1337 |
const transcriptInput = form.querySelector('#transcript');
|
| 1338 |
const apiKeyInput = form.querySelector('#anthropic_api_key');
|
| 1339 |
const previewMissing = document.getElementById('preview-missing');
|
| 1340 |
+
const previewActions = document.getElementById('preview-actions');
|
| 1341 |
|
| 1342 |
function updatePreviewButtons() {
|
| 1343 |
const hasVideo = !!(videoInput.files && videoInput.files[0]);
|
| 1344 |
const hasTranscript = !!(transcriptInput && transcriptInput.files && transcriptInput.files[0]);
|
| 1345 |
const hasKey = !!(apiKeyInput && apiKeyInput.value.trim());
|
| 1346 |
+
// Mode flips visually: with-key promotes the AI topic button and
|
| 1347 |
+
// demotes the plain scene picker to a small text link; no-key
|
| 1348 |
+
// hides the AI button and leaves the plain picker as the only
|
| 1349 |
+
// (and therefore primary-styled) CTA.
|
| 1350 |
+
if (previewActions) {
|
| 1351 |
+
previewActions.dataset.mode = hasKey ? 'with-key' : 'no-key';
|
| 1352 |
+
}
|
| 1353 |
previewBtn.disabled = !hasVideo;
|
| 1354 |
topicPreviewBtn.disabled = !(hasVideo && hasTranscript && hasKey);
|
| 1355 |
// Surface the exact missing input(s) so the user doesn't have to
|
| 1356 |
// hunt around for why the button is greyed out. Empty string
|
| 1357 |
// hides the line entirely via the :empty CSS rule.
|
| 1358 |
if (previewMissing) {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1359 |
if (!hasVideo) {
|
| 1360 |
+
previewMissing.textContent = 'Add a video to enable preview.';
|
| 1361 |
+
} else if (hasKey && (!hasTranscript)) {
|
| 1362 |
+
// AI mode is active and needs the transcript to run topics.
|
| 1363 |
+
previewMissing.textContent = 'Add a transcript to enable AI topic preview.';
|
|
|
|
|
|
|
| 1364 |
} else {
|
| 1365 |
previewMissing.textContent = '';
|
| 1366 |
}
|