585f302908
When user picks "自动", the client sends styleGuide="auto" to the server. The orchestrator then runs a lightweight style-selector LLM call in parallel with the Architect — both only depend on worldSetting, so there is zero added latency. The selector picks the best-matching preset from STYLE_MAP based on genre, mood, and setting. Also moves STYLE_MAP from page.tsx to lib/options.ts so it can be shared between client and server. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { chat } from "@infiplot/ai-client";
|
|
import type { ProviderConfig } from "@infiplot/types";
|
|
import { STYLE_MAP } from "@/lib/options";
|
|
|
|
const STYLE_NAMES = Object.keys(STYLE_MAP);
|
|
|
|
const SYSTEM = `You are an art director for a visual novel. Given the story premise, pick the single best-matching art style from the list below. Consider the genre, mood, setting, and target audience.
|
|
|
|
Available styles:
|
|
${STYLE_NAMES.map((s) => `- ${s}`).join("\n")}
|
|
|
|
Reply with ONLY the style name, nothing else. If uncertain, default to 吉卜力.`;
|
|
|
|
export async function selectStyle(
|
|
textConfig: ProviderConfig,
|
|
worldSetting: string,
|
|
): Promise<string> {
|
|
const result = await chat(
|
|
textConfig,
|
|
[
|
|
{ role: "system", content: SYSTEM },
|
|
{ role: "user", content: worldSetting },
|
|
],
|
|
{ temperature: 0, tag: "styleSelector" },
|
|
);
|
|
|
|
const picked = result.trim();
|
|
if (STYLE_MAP[picked]) {
|
|
return STYLE_MAP[picked];
|
|
}
|
|
const fuzzy = STYLE_NAMES.find((s) => picked.includes(s) || s.includes(picked));
|
|
if (fuzzy) {
|
|
return STYLE_MAP[fuzzy]!;
|
|
}
|
|
console.warn(`[styleSelector] unrecognized style "${picked}", falling back to 吉卜力`);
|
|
return STYLE_MAP["吉卜力"]!;
|
|
}
|