22
This commit is contained in:
66
scripts/nodejs/video_rewrite_optimizer.js
Normal file
66
scripts/nodejs/video_rewrite_optimizer.js
Normal file
@@ -0,0 +1,66 @@
|
||||
"use strict";
|
||||
|
||||
/** 仿写提示词(对齐 zhenqianba VideoRewriteOptimizer) */
|
||||
|
||||
class VideoRewriteOptimizer {
|
||||
static replacePromptVariables(template, content) {
|
||||
return String(template)
|
||||
.replace(/\{\{content\}\}/g, content)
|
||||
.replace(/\{content\}/g, content)
|
||||
.replace(/\{\{text\}\}/g, content)
|
||||
.replace(/\{text\}/g, content);
|
||||
}
|
||||
|
||||
static getStyleGuide(style) {
|
||||
const guides = {
|
||||
casual: "轻松随意、接地气、易产生共鸣,像和朋友聊天一样",
|
||||
professional: "正式专业、有信服力、适合商务或教育内容",
|
||||
emotional: "充满情感、富有感染力、能打动人心",
|
||||
humorous: "幽默诙谐、容易引起笑声和转发、保持积极态度",
|
||||
};
|
||||
return guides[style] || guides.casual;
|
||||
}
|
||||
|
||||
static getLengthGuide(length) {
|
||||
const guides = {
|
||||
short: "简洁有力,100字以内,快速传达核心信息",
|
||||
medium: "适中篇幅,100-300字,既能完整表达又不显冗长",
|
||||
long: "详细深入,300-500字,充分展开论点和细节",
|
||||
};
|
||||
return guides[length] || guides.medium;
|
||||
}
|
||||
|
||||
static buildDefaultPrompt(content, config) {
|
||||
const cfg = config || {};
|
||||
const styleGuide = this.getStyleGuide(cfg.style || "casual");
|
||||
const lengthGuide = this.getLengthGuide(cfg.length || "medium");
|
||||
return `你是一个专业的视频内容创意编写专家,擅长创作吸引人的视频文案。
|
||||
|
||||
## 原始文案:
|
||||
${content}
|
||||
|
||||
## 仿写要求:
|
||||
1. **风格**: ${styleGuide}
|
||||
2. **长度**: ${lengthGuide}
|
||||
3. **核心保持**: 保留原文案的核心信息和主题
|
||||
4. **创意提升**: 在措辞、表述角度、情感吸引力上创新
|
||||
5. **格式**:
|
||||
${cfg.keepHashtags !== false ? "- 保留原有话题标签(#开头的内容)" : "- 不使用话题标签"}
|
||||
${cfg.keepEmoji !== false ? "- 可以适当添加表情符号增加生动性" : "- 不使用表情符号"}
|
||||
6. **禁止事项**:
|
||||
- 不要改变事实信息
|
||||
- 不要添加虚假承诺
|
||||
- 不要包含敏感词汇
|
||||
|
||||
请直接输出仿写后的文案,不需要任何额外说明或标记。`;
|
||||
}
|
||||
|
||||
static buildRewritePrompt(content, config = {}, customPrompt) {
|
||||
if (customPrompt && String(customPrompt).trim()) {
|
||||
return this.replacePromptVariables(customPrompt, content);
|
||||
}
|
||||
return this.buildDefaultPrompt(content, config);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { VideoRewriteOptimizer };
|
||||
Reference in New Issue
Block a user