/** * AI Prompt 組裝工具 * 所有 Prompt 組裝邏輯只存在於此 */ export interface StoryboardInput { story: string style?: string pace?: string styleImage?: string // base64 圖片用於風格分析 } export interface StoryAnalysisInput { story: string style?: string styleImage?: string } export interface AssetGenerationInput { story: string analysis: string characterName?: string sceneName?: string } export interface CameraAnalysisInput { image?: string description?: string } export interface VideoPlanInput { prompt: string } export interface EditSuggestionInput { materials: string storyline: string } /** * 分析故事 Prompt */ export function buildStoryAnalysisPrompt(input: StoryAnalysisInput): string { const { story, style, styleImage } = input let prompt = `請分析以下故事,提取關鍵資訊。請以 JSON 格式回傳,結構如下: { "title": "故事標題", "summary": "故事摘要", "characters": [ { "id": "character_1", "name": "角色名稱", "description": "角色描述", "role": "角色定位(主角、配角等)" } ], "scenes": [ { "id": "scene_1", "name": "場景名稱", "description": "場景描述", "environment": "環境設定" } ], "suggestedStyle": "建議的視覺風格", "suggestedPace": "建議的節奏" } 故事內容: ${story}` if (style) { prompt += `\n\n風格要求:${style}` } if (styleImage) { prompt += `\n\n已提供風格參考圖片,請分析圖片中的視覺風格特徵並應用。` } prompt += `\n\n請確保回傳的是有效的 JSON 格式,可以直接被解析。` return prompt } /** * 生成人物三視圖 Prompt */ export function buildCharacterViewPrompt(input: AssetGenerationInput): string { return `請為角色「${input.characterName || '角色'}」生成白色背景的三視圖(正面、側面、背面)。 角色描述:${input.analysis} 請以 JSON 格式回傳,包含三視圖的描述或生成指令: { "characterName": "角色名稱", "frontView": "正面視圖描述", "sideView": "側面視圖描述", "backView": "背面視圖描述", "description": "角色詳細描述" } 請確保回傳的是有效的 JSON 格式。` } /** * 生成場景 Prompt */ export function buildScenePrompt(input: AssetGenerationInput): string { return `請為場景「${input.sceneName || '場景'}」生成白色背景的場景圖。 場景描述:${input.analysis} 請以 JSON 格式回傳: { "sceneName": "場景名稱", "description": "場景詳細描述", "environment": "環境設定", "lighting": "光線建議", "props": ["道具1", "道具2"], "imageDescription": "場景圖片描述" } 請確保回傳的是有效的 JSON 格式。` } /** * 生成分鏡表 Prompt */ export function buildStoryboardPrompt(input: StoryboardInput): string { const { story, style, pace, styleImage } = input let prompt = `請為以下故事生成分鏡表。請以 JSON 格式回傳,結構如下: { "title": "標題", "style": "風格描述", "pace": "節奏描述", "shots": [ { "shotNumber": 1, "camera": { "shot": "鏡頭類型(如:Extreme Long Shot, Long Shot, Medium Shot, Close-Up 等)", "movement": "運鏡方式(如:Pan, Tilt, Dolly In/Out, Truck, Crane, Handheld 等)", "composition": "構圖方式(如:Rule of Thirds, Leading Lines, Depth of Field 等)", "lighting": "光線設定(如:Three-Point Lighting, High Key, Low Key 等)", "description": "鏡頭詳細描述" }, "scene": "場景描述", "dialogue": "對話或旁白(選填)", "duration": 時長秒數(選填) } ] } 故事內容: ${story}` if (style) { prompt += `\n\n風格要求:${style}` } if (pace) { prompt += `\n\n節奏要求:${pace}` } if (styleImage) { prompt += `\n\n已提供風格參考圖片,請參考圖片中的視覺風格。` } prompt += `\n\n請確保回傳的是有效的 JSON 格式,可以直接被解析。` return prompt } /** * 生成攝影機分析 Prompt */ export function buildCameraAnalysisPrompt(input: CameraAnalysisInput): string { let prompt = `請分析以下影像的攝影機鏡位與運鏡建議。請以 JSON 格式回傳,結構如下: { "camera": { "shot": "建議的鏡頭類型", "movement": "建議的運鏡方式", "composition": "構圖分析", "lighting": "光線分析", "description": "詳細分析與建議" } }` if (input.image) { prompt += `\n\n圖片已上傳(base64 或 URL)` } if (input.description) { prompt += `\n\n影像描述:${input.description}` } prompt += `\n\n請確保回傳的是有效的 JSON 格式,可以直接被解析。` return prompt } /** * 生成影片規劃 Prompt */ export function buildVideoPlanPrompt(input: VideoPlanInput): string { return `請為以下 prompt 生成詳細的影片規劃。請以結構化的文字格式回傳,包含: - 影片主題與概念 - 分鏡建議 - 視覺風格 - 節奏與剪輯建議 Prompt:${input.prompt} 請提供詳細且實用的規劃建議。` } /** * 生成剪輯建議 Prompt */ export function buildEditSuggestionPrompt(input: EditSuggestionInput): string { return `請根據以下素材和劇情,提供剪輯建議。請以結構化的文字格式回傳,包含: - 剪輯順序建議 - 轉場方式 - 節奏控制 - 重點鏡頭選擇 素材描述:${input.materials} 劇情:${input.storyline} 請提供詳細且實用的剪輯建議。` }