compressContext 压缩上下文
(context string)
| 599 | |
| 600 | // compressContext 压缩上下文 |
| 601 | func (r *RAG) compressContext(context string) string { |
| 602 | // TODO: 实现更智能的上下文压缩 |
| 603 | // 现在只是简单截断 |
| 604 | if len(context) <= r.config.MaxContextLength { |
| 605 | return context |
| 606 | } |
| 607 | |
| 608 | return context[:r.config.MaxContextLength-3] + "..." |
| 609 | } |
| 610 | |
| 611 | // enhanceQuery 增强查询 |
| 612 | func (r *RAG) enhanceQuery(originalQuery string, items []*RetrievalItem) string { |