| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- // AI 扩写(LLM variant)搜索词的提示词解释:从 RunDashboardPage 抽出,供发现旅程视频详情复用。
- import { compactValue } from "@/lib/status/status";
- export function isLlmVariantQuery(query: Record<string, unknown>): boolean {
- return query.search_query_generation_method === "llm_variant";
- }
- export function seedTermForQuery(query: Record<string, unknown>): unknown {
- const seedRef =
- query.pattern_seed_ref && typeof query.pattern_seed_ref === "object"
- ? (query.pattern_seed_ref as Record<string, unknown>)
- : {};
- const llmInput =
- query.llm_input_evidence && typeof query.llm_input_evidence === "object"
- ? (query.llm_input_evidence as Record<string, unknown>)
- : {};
- return llmInput.seed_term || seedRef.seed_term || query.search_query;
- }
- export function llmVariantPromptPayload(query: Record<string, unknown>): Record<string, unknown> {
- const llmInput =
- query.llm_input_evidence && typeof query.llm_input_evidence === "object"
- ? (query.llm_input_evidence as Record<string, unknown>)
- : {};
- const seedTerm = seedTermForQuery(query);
- return {
- "这个提示词在做什么": "拿一个 DemandAgent 种子词,结合 Pattern 证据,让 LLM 生成一条相邻但不重复的抖音搜索 query。",
- "种子词": seedTerm,
- "生成结果": query.search_query,
- "父 query": query.llm_variant_of || "无",
- "提示词版本": query.llm_prompt_version || "query_variant.v1",
- "LLM 模型": query.llm_generation_model || "缺失",
- messages: [
- {
- role: "system",
- content:
- "You generate one concise Chinese short-video search query. " +
- "Return exactly one plain query string. Do not return JSON, " +
- "lists, quotes, explanations, or multiple lines."
- },
- {
- role: "user",
- content: [
- "Seed term:",
- compactValue(seedTerm),
- "",
- "Evidence context:",
- JSON.stringify(llmInput, null, 2),
- "",
- "Create one adjacent search phrase that stays faithful to the evidence. Avoid any phrase listed in existing_search_queries."
- ].join("\n")
- }
- ],
- "输入证据摘要": {
- seed_terms: llmInput.seed_terms,
- itemset_ids: llmInput.itemset_ids,
- category_bindings: llmInput.category_bindings,
- element_bindings: llmInput.element_bindings,
- existing_search_queries: llmInput.existing_search_queries
- }
- };
- }
|