Admin: the yearly forecast prompt is editable and can be tried on own forecasts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -28,6 +28,13 @@ const KINDS: { kind: PromptKind; id: string; label: string; about: string }[] =
|
||||
label: "Kapcsolati elemzés",
|
||||
about: "Fizetős összevetés-elemzés két képletről: öt fejezet, erősségek, kihívások és útravaló. Kérésre készül.",
|
||||
},
|
||||
{
|
||||
kind: "forecast",
|
||||
id: "elorejelzes",
|
||||
label: "Éves előrejelzés",
|
||||
about:
|
||||
"Fizetős elemzés egy születésnaptól a következőig: szolár, lassú tranzitok, progresszió, profekció, fogyatkozások. Öt fejezet, lehetőségek, kihívások és útravaló. Kérésre készül.",
|
||||
},
|
||||
];
|
||||
|
||||
const LANGUAGES: Record<string, string> = { hu: "Magyar", en: "Angol" };
|
||||
|
||||
@@ -7,7 +7,7 @@ import { AnalysisView } from "@/components/AnalysisView";
|
||||
import { api, errorText } from "@/lib/api";
|
||||
import { formatDate } from "@/lib/astro";
|
||||
import { listName } from "@/lib/synastry";
|
||||
import type { ChartListItem, PromptKind, PromptPreview, SynastryListItem } from "@/lib/types";
|
||||
import type { ChartListItem, ForecastList, ForecastSummary, PromptKind, PromptPreview, SynastryListItem } from "@/lib/types";
|
||||
|
||||
const POLL_MS = 4000;
|
||||
const MAX_POLLS = 150; // 10 minutes
|
||||
@@ -36,6 +36,7 @@ export function PromptTrial({
|
||||
onLoad: (system: string) => void;
|
||||
}) {
|
||||
const synastry = kind === "synastry";
|
||||
const forecastKind = kind === "forecast";
|
||||
const [chartId, setChartId] = useState(charts.find((c) => c.is_primary)?.id ?? charts[0]?.id ?? "");
|
||||
const [synastries, setSynastries] = useState<SynastryListItem[]>([]);
|
||||
const [synastryId, setSynastryId] = useState("");
|
||||
@@ -50,7 +51,23 @@ export function PromptTrial({
|
||||
})
|
||||
.catch(() => setSynastries([]));
|
||||
}, [synastry]);
|
||||
const targetId = synastry ? synastryId : chartId;
|
||||
// A forecast is tried on one of the chosen chart's calculated years.
|
||||
const [forecasts, setForecasts] = useState<ForecastSummary[] | null>(null);
|
||||
const [forecastId, setForecastId] = useState("");
|
||||
const [allForecasts, setAllForecasts] = useState<ForecastSummary[]>([]);
|
||||
useEffect(() => {
|
||||
if (!forecastKind || !chartId) return;
|
||||
setForecasts(null);
|
||||
api<ForecastList>(`/charts/${chartId}/forecasts`)
|
||||
.then((d) => {
|
||||
setForecasts(d.forecasts);
|
||||
setForecastId(d.forecasts[0]?.id ?? "");
|
||||
setAllForecasts((all) => [...all.filter((f) => f.chart_id !== chartId), ...d.forecasts]);
|
||||
})
|
||||
.catch(() => setForecasts([]));
|
||||
}, [forecastKind, chartId]);
|
||||
const targetId = synastry ? synastryId : forecastKind ? forecastId : chartId;
|
||||
const forecastName = (f: ForecastSummary) => `${f.year}–${f.year + 1} · ${f.place ?? "születési hely"}`;
|
||||
const comparisonName = (s: SynastryListItem) => `${listName(s.chart1, charts)} és ${listName(s.chart2, charts)}`;
|
||||
const [trials, setTrials] = useState<Trial[]>([]);
|
||||
const [busy, setBusy] = useState(false);
|
||||
@@ -62,7 +79,11 @@ export function PromptTrial({
|
||||
setError(null);
|
||||
try {
|
||||
const preview = await api<PromptPreview>(`/admin/prompts/${kind}/${language}/preview`, {
|
||||
body: synastry ? { system: draft, synastry_id: synastryId } : { system: draft, chart_id: chartId },
|
||||
body: synastry
|
||||
? { system: draft, synastry_id: synastryId }
|
||||
: forecastKind
|
||||
? { system: draft, forecast_id: forecastId }
|
||||
: { system: draft, chart_id: chartId },
|
||||
});
|
||||
setTrials((all) => [{ preview, system: draft }, ...all]);
|
||||
} catch (e) {
|
||||
@@ -84,7 +105,8 @@ export function PromptTrial({
|
||||
<h2 id={`${selectId}-title`}>Kipróbálás</h2>
|
||||
<p className="hint">
|
||||
A szerkesztőben lévő szöveggel (mentés nélkül is) megírja az elemzést egy saját{" "}
|
||||
{synastry ? "összevetésedre" : "képletedre"}. Az eredmény nem kerül {synastry ? "az összevetéshez" : "a képlethez"},
|
||||
{synastry ? "összevetésedre" : forecastKind ? "előrejelzésedre" : "képletedre"}. Az eredmény nem kerül{" "}
|
||||
{synastry ? "az összevetéshez" : forecastKind ? "az előrejelzéshez" : "a képlethez"},
|
||||
csak itt látod. Valódi modellhívás, ezért költsége van.
|
||||
</p>
|
||||
</div>
|
||||
@@ -110,6 +132,54 @@ export function PromptTrial({
|
||||
</div>
|
||||
) : charts.length === 0 ? (
|
||||
<p className="muted">Kipróbáláshoz előbb legyen legalább egy képleted.</p>
|
||||
) : forecastKind ? (
|
||||
<div className="prompt-trial-form">
|
||||
<div className="field">
|
||||
<label htmlFor={selectId}>Képlet</label>
|
||||
<select id={selectId} className="inp" value={chartId} onChange={(e) => setChartId(e.target.value)}>
|
||||
{charts.map((c) => (
|
||||
<option key={c.id} value={c.id}>
|
||||
{c.is_primary ? `Én (${c.label})` : c.label}
|
||||
{c.birth.time ? "" : " – idő nélkül"}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
{forecasts === null ? (
|
||||
<p className="hint">Betöltés…</p>
|
||||
) : forecasts.length === 0 ? (
|
||||
<p className="muted">
|
||||
Ehhez a képlethez még nincs kiszámolt év. Előbb kérj egyet az{" "}
|
||||
<a href={`/kepletek/${chartId}/elorejelzes`}>előrejelzés oldalán</a> (a számítás ingyenes).
|
||||
</p>
|
||||
) : (
|
||||
<>
|
||||
<div className="field">
|
||||
<label htmlFor={`${selectId}-year`}>Év</label>
|
||||
<select
|
||||
id={`${selectId}-year`}
|
||||
className="inp"
|
||||
value={forecastId}
|
||||
onChange={(e) => setForecastId(e.target.value)}
|
||||
>
|
||||
{forecasts.map((f) => (
|
||||
<option key={f.id} value={f.id}>
|
||||
{forecastName(f)}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-primary"
|
||||
onClick={start}
|
||||
disabled={busy || !targetId || !draft.trim()}
|
||||
>
|
||||
{busy ? "Indítás…" : "Kipróbálás"}
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<div className="prompt-trial-form">
|
||||
<div className="field">
|
||||
@@ -138,7 +208,13 @@ export function PromptTrial({
|
||||
key={t.preview.id}
|
||||
trial={t}
|
||||
chartLabel={
|
||||
t.preview.synastry_id
|
||||
t.preview.forecast_id
|
||||
? (() => {
|
||||
const f = allForecasts.find((x) => x.id === t.preview.forecast_id);
|
||||
const c = f && charts.find((x) => x.id === f.chart_id);
|
||||
return f ? `${c?.label ?? "Képlet"}, ${forecastName(f)}` : "Előrejelzés";
|
||||
})()
|
||||
: t.preview.synastry_id
|
||||
? (() => {
|
||||
const s = synastries.find((x) => x.id === t.preview.synastry_id);
|
||||
return s ? comparisonName(s) : "Összevetés";
|
||||
@@ -218,7 +294,13 @@ function TrialResult({
|
||||
{waiting ? (
|
||||
<AnalysisLoading
|
||||
compact
|
||||
text={p.kind === "summary" ? "Készül az összefoglaló, kb. 10–30 másodperc." : "Készül az elemzés, kb. 1–3 perc."}
|
||||
text={
|
||||
p.kind === "summary"
|
||||
? "Készül az összefoglaló, kb. 10–30 másodperc."
|
||||
: p.kind === "forecast"
|
||||
? "Készül az előrejelzés, kb. 2–4 perc."
|
||||
: "Készül az elemzés, kb. 1–3 perc."
|
||||
}
|
||||
/>
|
||||
) : p.status === "failed" ? (
|
||||
<p className="msg msg-error" role="alert">
|
||||
@@ -231,7 +313,7 @@ function TrialResult({
|
||||
<p className="summary-text">{p.content.summary}</p>
|
||||
</div>
|
||||
) : (
|
||||
<AnalysisView content={p.content} kind={p.kind === "synastry" ? "synastry" : "natal"} />
|
||||
<AnalysisView content={p.content} kind={p.kind} />
|
||||
)
|
||||
) : null}
|
||||
{meta.length > 0 && !waiting && <p className="hint">{meta.join(" · ")}</p>}
|
||||
|
||||
@@ -229,7 +229,7 @@ export interface AdminUser {
|
||||
analyses_left: UnitBalance;
|
||||
}
|
||||
|
||||
export type PromptKind = "summary" | "natal" | "synastry";
|
||||
export type PromptKind = "summary" | "natal" | "synastry" | "forecast";
|
||||
|
||||
export interface PromptRevision {
|
||||
id: number;
|
||||
@@ -261,6 +261,7 @@ export interface PromptPreview {
|
||||
kind: PromptKind;
|
||||
chart_id: string | null;
|
||||
synastry_id: string | null;
|
||||
forecast_id: string | null;
|
||||
language: string;
|
||||
model: string;
|
||||
status: "pending" | "running" | "done" | "failed";
|
||||
|
||||
Reference in New Issue
Block a user