Validate 验证知识项
(ctx context.Context, id string)
| 708 | |
| 709 | // Validate 验证知识项 |
| 710 | func (m *manager) Validate(ctx context.Context, id string) (bool, []string, error) { |
| 711 | item, err := m.Get(ctx, id) |
| 712 | if err != nil { |
| 713 | return false, nil, fmt.Errorf("knowledge: failed to get item for validation: %w", err) |
| 714 | } |
| 715 | |
| 716 | var warnings []string |
| 717 | |
| 718 | // 检查置信度 |
| 719 | if item.Confidence < m.config.MinConfidence { |
| 720 | warnings = append(warnings, fmt.Sprintf("confidence %.2f is below threshold %.2f", item.Confidence, m.config.MinConfidence)) |
| 721 | } |
| 722 | |
| 723 | // 检查质量 |
| 724 | if item.Quality < m.config.MinQuality { |
| 725 | warnings = append(warnings, fmt.Sprintf("quality %.2f is below threshold %.2f", item.Quality, m.config.MinQuality)) |
| 726 | } |
| 727 | |
| 728 | // 检查时效性 |
| 729 | if item.ExpiresAt != nil && time.Now().After(*item.ExpiresAt) { |
| 730 | warnings = append(warnings, "knowledge item has expired") |
| 731 | } |
| 732 | |
| 733 | isValid := len(warnings) == 0 |
| 734 | return isValid, warnings, nil |
| 735 | } |
| 736 | |
| 737 | // Refresh 刷新知识项 |
| 738 | func (m *manager) Refresh(ctx context.Context, id string) error { |