MCPcopy Create free account
hub / github.com/astercloud/aster / extractKeyTopics

Function extractKeyTopics

pkg/session/summary.go:254–283  ·  view source on GitHub ↗

extractKeyTopics 从摘要中提取关键主题

(summary string)

Source from the content-addressed store, hash-verified

252
253// extractKeyTopics 从摘要中提取关键主题
254func extractKeyTopics(summary string) []string {
255 topics := []string{}
256
257 // 简单的主题提取逻辑
258 lines := strings.Split(summary, "\n")
259 inTopicsSection := false
260
261 for _, line := range lines {
262 line = strings.TrimSpace(line)
263
264 if strings.Contains(strings.ToLower(line), "main topics") {
265 inTopicsSection = true
266 continue
267 }
268
269 if inTopicsSection {
270 if strings.HasPrefix(line, "-") || strings.HasPrefix(line, "*") {
271 topic := strings.TrimSpace(strings.TrimPrefix(strings.TrimPrefix(line, "-"), "*"))
272 if topic != "" {
273 topics = append(topics, topic)
274 }
275 } else if strings.HasPrefix(line, "#") {
276 // 遇到新的标题,退出主题部分
277 break
278 }
279 }
280 }
281
282 return topics
283}
284
285// extractParticipants 提取参与者
286func extractParticipants(messages []types.Message) []string {

Callers 2

SummarizeSessionMethod · 0.85
SummarizeIncrementalMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected