ai-cut/app/utils/ai/prompts.ts

233 lines
5.6 KiB
TypeScript
Raw Normal View History

2025-12-16 10:08:51 +00:00
/**
* 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}
`
}