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

Function TestSuggestImprovements

pkg/memory/quality_analyzer_test.go:423–463  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

421}
422
423func TestSuggestImprovements(t *testing.T) {
424 config := DefaultQualityMetricsConfig()
425 config.MinQualityThreshold = 0.5
426 qm := NewQualityMetrics(config)
427 qa := NewQualityAnalyzer(qm, nil)
428
429 // 添加低质量记忆
430 lowQualityMem := &MemoryWithScore{
431 DocID: "low-quality",
432 Text: "Short",
433 Provenance: NewProvenance(SourceUserInput, "user-1"),
434 Score: 0.2,
435 }
436 lowQualityMem.Provenance.Confidence = 0.3
437
438 _, _ = qm.Evaluate(context.Background(), "low-quality", lowQualityMem)
439
440 // 获取改进建议
441 improvements, err := qa.SuggestImprovements(context.Background())
442 if err != nil {
443 t.Fatalf("SuggestImprovements failed: %v", err)
444 }
445
446 // 应该有改进建议
447 if len(improvements) == 0 {
448 t.Error("should have improvement suggestions for low quality memory")
449 }
450
451 // 验证建议内容
452 if len(improvements) > 0 {
453 imp := improvements[0]
454
455 if imp.MemoryID != "low-quality" {
456 t.Errorf("MemoryID = %s, want low-quality", imp.MemoryID)
457 }
458
459 if len(imp.Suggestions) == 0 {
460 t.Error("should have specific suggestions")
461 }
462 }
463}
464
465func TestTruncate(t *testing.T) {
466 tests := []struct {

Callers

nothing calls this directly

Calls 7

EvaluateMethod · 0.95
SuggestImprovementsMethod · 0.95
NewQualityMetricsFunction · 0.85
NewQualityAnalyzerFunction · 0.85
NewProvenanceFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected