* 构建带额外要求的 Prompt
( basePrompt: string, content: string, extraRequirements?: string )
| 120 | * 构建带额外要求的 Prompt |
| 121 | */ |
| 122 | function buildPromptWithRequirements( |
| 123 | basePrompt: string, |
| 124 | content: string, |
| 125 | extraRequirements?: string |
| 126 | ): string { |
| 127 | let prompt = basePrompt.replace('{content}', truncateContent(content)) |
| 128 | if (extraRequirements?.trim()) { |
| 129 | // 在标题/话题名称之前插入额外要求 |
| 130 | prompt = prompt.replace(/(标题|话题名称):$/, `\n额外要求:${extraRequirements.trim()}\n\n$1:`) |
| 131 | } |
| 132 | return prompt |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * 截断内容到指定长度 |
no test coverage detected