prompt.ts
4.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import type { writePromptParam } from "@/app/types/prompt";
//生成文章提示词
export function getWrtingPrompt(param: writePromptParam): string {
const {
isImgName,
writingPurposeName: rawPurpose,
writingStyleName: rawStyle,
writingTypeName: rawType,
writingLanguageName,
prompt,
writingCount,
fileData,
} = param;
console.log("********************", fileData);
console.log("**********************", prompt);
// 根据用途调整文案类型描述
const purposeMap: Record<string, string> = {
公司官网: "正式的公司官网文案",
小红书: "符合小红书平台风格的文案",
微信公众号: "适合微信公众号传播的文案",
今日头条: "今日头条风格的热点文案",
};
const styleMap: Record<string, string> = {
专业: "专业严谨",
活泼: "生动活泼",
严谨: "严谨细致",
俏皮: "俏皮可爱",
幽默: "幽默风趣",
夸张: "夸张吸睛",
可爱: "可爱亲切",
丰满: "内容丰满",
健康: "健康积极",
};
const typeMap: Record<string, string> = {
产品推广文案: "产品推广的文案",
品牌宣传文案: "品牌宣传的文案",
产品说明书: "产品的说明书",
产品介绍: "产品的介绍",
};
let isImg = "";
if (isImgName === "是") {
const purpose = purposeMap[rawPurpose] || "公司官网的介绍";
const style = styleMap[rawStyle] || "专业的风格";
isImg = `要求图文混排,需符合以下要求:
文案要配上图片,实现图文混排,要美观,要符合${purpose}的排版标准和写作风格,写作风格要${style},
你没有图片没关系,把图文混排的效果实现,并在你认为要插入图片的地方将图片的Prompt用英文输出给:,记得图片地址后面的?nologo=true一定不能去掉了,
因为这个语法可以自动按照提示生成并渲染图片。你可以帮我大幅提高生成图片质量和丰富程度,比如增加相机光圈、具体场景描述等内容,注意图片一定要用<img,否则在HTML下图片可能显示不了`;
}
const writingTypeName = typeMap[rawType] || "产品推广文案";
let filePrompt = "";
if (fileData) {
filePrompt = `并结合以下文件内容:
${fileData}
`;
}
return `请用${writingLanguageName}撰写一篇关于【${prompt}】的${writingTypeName}:
${isImg}
${filePrompt}
具体要求:
1. 写作风格:${styleMap[rawStyle] || "专业"}
2. 字数要求:不少于${writingCount}字(不计代码)
3. 输出格式:标准HTML带行内样式,并且样式能够支持tinymce富文本编辑器
4. 特殊要求:直接输出结果,不要额外解释`;
}
//生成图片提示词
export function getBgPrompt(content: string) {
const input = `你现扮演生成创意思图片的提示词工程师,参考我的描述“${content}”帮我做优化润色5组,返回的数据用''分割,直接输出结果,不要做解释`;
return input;
}
//思维导图提示词
export function getMindPrompt(content: string, isContext: boolean) {
const context = `联系上下文`;
let prompt = `请你帮我生成一份以"${content}"为主题的思维导图数据,请严格遵循以下要求生成思维导图数据:
1. 所有键名必须使用双引号
2. 所有字符串值必须使用双引号
3. 确保没有尾随逗号
4. 按这个模板结构生成::{
"nodeData": {
"id": "root",
"topic": "中心主题",
"children": [
{
"id": "d451a724b7c10970",
"topic": "sub1",
"children": [
{
"id": "d451a77ca7348eae",
"topic": "sub2",
},],
},
],
},}
只需要返回数据,不要做任何解释
`;
if (isContext) {
prompt = context + prompt;
}
return prompt;
}