Files
SlabUploader/frontend/src/create/inference/GenerateText.svelte
T
grokbot_ty c25e3f4927 feat(call2): short/long desc structure in seed (not brand voice)
Call 2 seed now requires benefit-first short + four-part long HTML, returned
as JSON. POST parses and persists both fields; Create-desc gate no longer
requires short (Call 2 writes it). Brand voice/geo stay Settings-injected.
2026-09-26 10:35:53 -07:00

86 lines
2.7 KiB
Svelte

<script lang="ts">
let slabId = '';
let contentEnabled = false;
let reachable = false;
let description: string | null = null;
let shortDescription: string | null = null;
let error = '';
let busy = false;
async function checkReadiness() {
contentEnabled = false;
reachable = false;
try {
const [inf, test] = await Promise.all([
fetch('/api/v1/settings').then((r) => r.json()),
fetch('/api/v1/admin/test-inference', { method: 'POST' }).then((r) => r.json()),
]);
contentEnabled = inf.content_llm_enabled === 'true' || inf.content_llm_enabled === true;
reachable = test.ok === true;
} catch {
reachable = false;
}
}
async function generate() {
if (!slabId) {
error = 'Enter a slab id.';
return;
}
busy = true;
error = '';
description = null;
shortDescription = null;
try {
const res = await fetch(`/api/v1/slabs/${encodeURIComponent(slabId)}/inference/call2`, { method: 'POST' });
const body = await res.json();
if (res.ok) {
description = body.description;
shortDescription = body.short_description ?? null;
}
else error = body.error?.message || `call2 failed (${res.status})`;
} catch {
error = 'network error';
}
busy = false;
}
checkReadiness();
</script>
<div class="inference">
<h2>Generate text</h2>
<p class="state">
Content generation: {contentEnabled ? 'on' : 'off'} · endpoint: {reachable ? 'reachable' : 'unreachable'}
</p>
<p class="note">Call 1 (vision classification) is disabled on this branch. Call 2 description generation stays.</p>
{#if !contentEnabled || !reachable}
<p class="note">The Generate text control is disabled: it appears only when content generation is
enabled and the inference endpoint is reachable.</p>
{:else}
<div>
<label>Slab ID</label>
<input bind:value={slabId} placeholder="uuid" />
</div>
<div class="row">
<button on:click={generate} disabled={busy}>{busy ? 'Working…' : 'Generate description (Call 2)'}</button>
</div>
{#if error}<p class="err">{error}</p>{/if}
{#if shortDescription}<p class="desc"><strong>Short:</strong> {shortDescription}</p>{/if}
{#if description}<p class="desc"><strong>Long:</strong> {description}</p>{/if}
{/if}
<button class="mini" on:click={checkReadiness}>Recheck readiness</button>
</div>
<style>
.inference { max-width: 560px; color: #eee; }
label { display: block; margin: 8px 0 4px; }
input { width: 100%; padding: 6px; }
.row { margin-top: 12px; display: flex; gap: 8px; }
.state { color: #aaa; }
.note { color: #e8a; }
.err { color: #e88; }
.desc { margin-top: 12px; }
.mini { margin-top: 12px; font-size: 12px; }
</style>