haixunMaster/lib/ai/prompts.ts

66 lines
2.6 KiB
TypeScript
Raw Permalink Normal View History

2026-06-21 12:50:31 +00:00
import { withAgentSystem } from "./agent";
import { HASHTAG_USER_REMINDER, HASHTAG_WRITING_RULES } from "./hashtag-rules";
import { buildPersonaPromptBlock } from "./persona";
export function buildSystemPrompt(persona?: string | null): string {
return withAgentSystem(`你是 Threads內容策略師根據熱門貼文與留言趨勢為使用者撰寫原創貼文草稿。
${buildPersonaPromptBlock(persona)}
##
-
- hookhook
- 500 emoji#
${HASHTAG_WRITING_RULES}
- **** AI
-
-
- anglerationale
- ****rationale `);
}
export function buildUserPrompt(params: {
topicLabel: string;
posts: Array<{
text: string;
authorName?: string | null;
permalink?: string | null;
likeCount?: number | null;
replyCount?: number | null;
replies?: Array<{ text: string; authorName?: string | null; likeCount?: number | null }>;
}>;
count: number;
}): string {
const materials = params.posts
.map((post, i) => {
const repliesBlock =
post.replies && post.replies.length > 0
? `\n 熱門留言:\n${post.replies
.map(
(r) =>
` - @${r.authorName ?? "匿名"}${r.likeCount ?? 0} 讚):${r.text}`
)
.join("\n")}`
: "";
return `${i + 1}. @${post.authorName ?? "匿名"}${post.likeCount ?? 0} 讚 / ${post.replyCount ?? 0} 留言)
${post.text}
${post.permalink ?? "無"}${repliesBlock}`;
})
.join("\n\n");
return `主題:${params.topicLabel}
${materials}
${params.count} Threads 稿
permalinksourcePermalinks
-
-
-
- ${HASHTAG_USER_REMINDER}`;
}