feat(*): 短剧创作工作台 - 完善章节分镜、资产管理、技能运行与生成任务恢复
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { buildSkillMentionReferences, renderSkillPrompt } from "@/lib/canvas/canvas-skill-mentions";
|
||||
import { buildSkillMentionReferences } from "@/services/skill-runtime";
|
||||
import { canvasResourceMentionToken, type CanvasResourceReference } from "@/lib/canvas/canvas-resource-references";
|
||||
import type { Skill } from "@/services/api/skills";
|
||||
import { creationAttachmentKind, type CreationAttachment } from "./creation-assets";
|
||||
@@ -78,10 +78,6 @@ export function expandCreationPrompt(prompt: string, references: CreationReferen
|
||||
const mediaMappings: string[] = [];
|
||||
const attachmentPositions = new Map(attachments.map((attachment, index) => [attachment.id, index + 1]));
|
||||
references.forEach((reference) => {
|
||||
if (reference.kind === "skill" && reference.skill) {
|
||||
contexts.push(renderSkillPrompt(reference.skill));
|
||||
return;
|
||||
}
|
||||
if (reference.attachmentId) {
|
||||
const position = attachmentPositions.get(reference.attachmentId);
|
||||
const kindLabel = reference.kind === "video" ? "视频" : reference.kind === "audio" ? "音频" : reference.kind === "text" ? "文件" : "图片";
|
||||
@@ -94,12 +90,6 @@ export function expandCreationPrompt(prompt: string, references: CreationReferen
|
||||
return [...contexts, `【创作要求】\n${visiblePrompt}`].filter(Boolean).join("\n\n");
|
||||
}
|
||||
|
||||
export function creationReferenceMetadata(references: CreationReference[]) {
|
||||
return {
|
||||
skillIds: references.flatMap((reference) => (reference.skill?.skill_id ? [reference.skill.skill_id] : [])),
|
||||
};
|
||||
}
|
||||
|
||||
function attachmentReference(attachment: CreationAttachment, index: number): CreationReference {
|
||||
const kind = creationAttachmentKind(attachment);
|
||||
const label = kind === "video" ? "视频" : kind === "audio" ? "音频" : kind === "file" ? "文件" : "图片";
|
||||
|
||||
@@ -43,7 +43,8 @@ import type { PromptOptimizerProvider } from "@/lib/plugins/plugin-types";
|
||||
import { promptOptimizerPlugin, PROMPT_OPTIMIZER_PLUGIN_ID } from "@/lib/plugins/builtin/prompt-optimizer";
|
||||
import { createPluginHostContext } from "@/services/plugin-host";
|
||||
import { usePluginStore } from "@/stores/use-plugin-store";
|
||||
import { buildCreationMentionReferences, creationReferenceMetadata, displayCreationPrompt, expandCreationPrompt, reconcileCreationAttachmentLimit, removeCreationReferenceTokens, replaceCreationAttachmentReference, selectedCreationReferences, type CreationReference } from "./creation-references";
|
||||
import { buildCreationMentionReferences, displayCreationPrompt, expandCreationPrompt, reconcileCreationAttachmentLimit, removeCreationReferenceTokens, replaceCreationAttachmentReference, selectedCreationReferences, type CreationReference } from "./creation-references";
|
||||
import { skillRuntime } from "@/services/skill-runtime";
|
||||
import { creationAttachmentFromAsset, creationAttachmentFromAudio, creationAttachmentFromAudioAsset, creationAttachmentFromDocument, creationAttachmentFromExternalAsset, creationAttachmentFromImage, creationAttachmentFromVideo, creationAttachmentFromVideoAsset, creationAttachmentKind, creationAudioAsset, creationFileAccepted, creationImageAsset, creationMediaAspectRatio, creationUploadAccept, creationVideoAsset, removeCreationAttachment, splitCreationAttachments, type CreationAttachment } from "./creation-assets";
|
||||
|
||||
type CreationMode = "text" | "image" | "video";
|
||||
@@ -386,7 +387,7 @@ export default function CreatePage() {
|
||||
category: asset.category || "other",
|
||||
kindLabel: asset.kind === "video" ? "视频" : asset.kind === "audio" ? "音频" : "图片",
|
||||
asset,
|
||||
searchText: asset.tags.join(" "),
|
||||
searchText: (asset.tags || []).join(" "),
|
||||
disabledReason: mode === "image" && asset.kind !== "image" ? "图片创作仅支持参考图" : undefined,
|
||||
})),
|
||||
...externalLibraryItems,
|
||||
@@ -566,8 +567,22 @@ export default function CreatePage() {
|
||||
audioCount: referenceAudios.length,
|
||||
characterCount: 0,
|
||||
});
|
||||
const expandedPrompt = expandCreationPrompt(text, references, attachments);
|
||||
const referenceMetadata = creationReferenceMetadata(references);
|
||||
const skillReferences = references.flatMap((reference) => (reference.skill ? [reference.skill] : []));
|
||||
let skillExecution: Awaited<ReturnType<typeof skillRuntime.prepare<"creation">>>;
|
||||
try {
|
||||
skillExecution = await skillRuntime.prepare({
|
||||
profile: "creation",
|
||||
prompt: expandCreationPrompt(text, references, attachments),
|
||||
skills: skillReferences,
|
||||
selectedSkillIds: skillReferences.map((skill) => skill.skill_id),
|
||||
});
|
||||
} catch (error) {
|
||||
toast.error(error instanceof Error ? error.message : "技能上下文加载失败");
|
||||
releaseRetryLock();
|
||||
return;
|
||||
}
|
||||
const expandedPrompt = skillExecution.prompt;
|
||||
const referenceMetadata = skillExecution.metadata;
|
||||
followLatestMessageRef.current = true;
|
||||
const userMessage = newMessage("user", text, { mode, model: selectedModel, attachments, references, settings });
|
||||
const assistantMessage = newMessage("assistant", "", { mode, model: selectedModel, status: mode === "text" ? "streaming" : "pending", settings, ...retryContext });
|
||||
|
||||
Reference in New Issue
Block a user