feat(kol): enrich assist generate with URL references and template prompt
- Add kolAssistURLResolver that fetches reference articles via the Ark
URL extractor when the user's description contains http(s) links, and
merges up to kolAssistReferenceContentMaxRunes of extracted content
into the generate description.
- Rewrite the generate user prompt into a strict template-authoring
brief: output only the final prompt template in Chinese, parameterize
variable info as {{placeholder}}, require at least 3 placeholders
when references exist, and cover goal/topic/title/structure/style/
interaction/constraints.
- Wire LLMConfig and logger through NewKolAssistService and the
handler.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -43,6 +43,9 @@ func (s *KolAssistService) Run(
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
if req.Mode == kolAssistModeGenerate {
|
||||
req.Description = s.enrichGenerateDescription(ctx, req.Description)
|
||||
}
|
||||
|
||||
generateReq, err := BuildKolAssistGenerateRequest(req)
|
||||
if err != nil {
|
||||
@@ -88,7 +91,21 @@ func BuildKolAssistGenerateRequest(req AssistRequest) (llm.GenerateRequest, erro
|
||||
func BuildKolAssistUserPrompt(req AssistRequest) (string, error) {
|
||||
switch strings.ToLower(strings.TrimSpace(req.Mode)) {
|
||||
case kolAssistModeGenerate:
|
||||
return req.Description, nil
|
||||
return strings.TrimSpace(fmt.Sprintf(`
|
||||
你的任务是把“用户需求 + 参考材料”转换成“最终可直接给另一个 AI 使用的提示词模板”。
|
||||
|
||||
严格要求:
|
||||
1. 只输出最终提示词模板,不要输出分析、总结、复盘、学习笔记、解释说明。
|
||||
2. 如果提供了参考文章或参考网页,只学习其选题切入、标题策略、结构框架、叙事节奏、风格语气、互动与转化方式,然后抽象成可复用规则。
|
||||
3. 任何会变化的信息都必须参数化成 {{变量名}} 占位符,不要把具体的人名、品牌、平台、标题、数字、时间、地区、产品、案例、链接、经历写死。
|
||||
4. 若用户基于具体文章/网页生成模板,结果中至少包含 3 个 {{}} 占位符。
|
||||
5. 结果必须是“生成同类内容”的模板,不是对参考文章的分析。
|
||||
6. 模板至少覆盖:创作目标、选题要求、标题要求、结构要求、风格要求、互动/转化要求、限制项。
|
||||
7. 输出中文,直接给出最终模板正文。
|
||||
|
||||
用户需求与参考材料:
|
||||
%s
|
||||
`, req.Description)), nil
|
||||
case kolAssistModeOptimize:
|
||||
schemaJSON := "null"
|
||||
if req.Schema != nil {
|
||||
|
||||
Reference in New Issue
Block a user