ai-chatbot/lib/video-canvas/video-marks.ts

24 lines
697 B
TypeScript

export const DEFAULT_VIDEO_MARK_GENERATION_PROMPT =
"重点遵循已标记元素:{{labels}}";
export function composeVideoMarkGenerationPrompt({
labels,
template,
}: {
labels: string[];
template?: string;
}) {
const normalizedLabels = Array.from(
new Set(labels.map((label) => String(label || "").trim()).filter(Boolean)),
);
if (normalizedLabels.length === 0) return "";
const source =
template === undefined ? DEFAULT_VIDEO_MARK_GENERATION_PROMPT : template.trim();
if (!source) return "";
return source
.replaceAll("{{labels}}", normalizedLabels.map((label) => `@${label}`).join("、"))
.replaceAll("{{plainLabels}}", normalizedLabels.join("、"));
}