buildIncrementalSummaryPrompt 构建增量摘要提示词
(previousSummary string, newMessages []types.Message)
| 205 | |
| 206 | // buildIncrementalSummaryPrompt 构建增量摘要提示词 |
| 207 | func (s *Summarizer) buildIncrementalSummaryPrompt(previousSummary string, newMessages []types.Message) string { |
| 208 | var prompt strings.Builder |
| 209 | |
| 210 | prompt.WriteString("Update the following conversation summary with new messages.\n\n") |
| 211 | prompt.WriteString("## Previous Summary\n\n") |
| 212 | prompt.WriteString(previousSummary) |
| 213 | prompt.WriteString("\n\n## New Messages\n\n") |
| 214 | |
| 215 | for i, msg := range newMessages { |
| 216 | role := string(msg.Role) |
| 217 | content := extractTextContent(msg) |
| 218 | |
| 219 | prompt.WriteString(fmt.Sprintf("**%s** (Message %d):\n", role, i+1)) |
| 220 | prompt.WriteString(content) |
| 221 | prompt.WriteString("\n\n") |
| 222 | } |
| 223 | |
| 224 | prompt.WriteString("## Updated Summary\n\n") |
| 225 | prompt.WriteString("Provide an updated summary that incorporates the new information.\n") |
| 226 | |
| 227 | return prompt.String() |
| 228 | } |
| 229 | |
| 230 | // SessionSummary Session 摘要 |
| 231 | type SessionSummary struct { |
no test coverage detected