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

Method formatContextItem

pkg/knowledge/rag.go:574–598  ·  view source on GitHub ↗

formatContextItem 格式化上下文项目

(item *KnowledgeItem)

Source from the content-addressed store, hash-verified

572
573// formatContextItem 格式化上下文项目
574func (r *RAG) formatContextItem(item *KnowledgeItem) string {
575 var parts []string
576
577 if item.Title != "" {
578 parts = append(parts, "## "+item.Title)
579 }
580
581 if item.Description != "" {
582 parts = append(parts, item.Description)
583 }
584
585 if item.Content != "" {
586 parts = append(parts, item.Content)
587 }
588
589 if len(item.Tags) > 0 {
590 parts = append(parts, "Tags: "+strings.Join(item.Tags, ", "))
591 }
592
593 if item.Source != "" {
594 parts = append(parts, "Source: "+item.Source)
595 }
596
597 return strings.Join(parts, "\n")
598}
599
600// compressContext 压缩上下文
601func (r *RAG) compressContext(context string) string {

Callers 1

generateContextMethod · 0.95

Calls 1

JoinMethod · 0.45

Tested by

no test coverage detected