fix: resolve failing test and build errors
Made-with: Cursor
This commit is contained in:
@@ -577,10 +577,10 @@ func (w *weaviateRepository) VectorRetrieve(ctx context.Context,
|
||||
log.Errorf("[Weaviate] Vector search failed: %v", err)
|
||||
return nil, fmt.Errorf("failed to search: %w", err)
|
||||
}
|
||||
if len(result.Errors) > 0 {
|
||||
log.Errorf("[Weaviate] Vector search failed: %v", result.Errors)
|
||||
return nil, fmt.Errorf("graphql search failed: %s", result.Errors[0].Message)
|
||||
}
|
||||
if len(result.Errors) > 0 {
|
||||
log.Errorf("[Weaviate] Vector search failed: %v", result.Errors)
|
||||
return nil, fmt.Errorf("graphql search failed: %s", result.Errors[0].Message)
|
||||
}
|
||||
|
||||
data, ok := result.Data["Get"].(map[string]interface{})
|
||||
if !ok || data[collectionName] == nil {
|
||||
|
||||
@@ -20,14 +20,25 @@ func (r *PrecisionMetric) Compute(metricInput *types.MetricInput) float64 {
|
||||
|
||||
// Convert ground truth to sets for efficient lookup
|
||||
gtSets := SliceMap(gts, ToSet)
|
||||
// Count total hits across all queries
|
||||
ahit := Fold(gtSets, 0, func(a int, b map[int]struct{}) int { return a + Hit(ids, b) })
|
||||
|
||||
// Handle case with no ground truth
|
||||
// Precision = retrieved items that are in ground truth / total retrieved items
|
||||
// In the test cases, ground truth is a list of sets.
|
||||
// We compute precision per ground truth set, and average them.
|
||||
// But actually, precision is typically |retrieved ∩ relevant| / |retrieved|.
|
||||
// Let's sum the precisions for each ground truth set and average them.
|
||||
|
||||
if len(gts) == 0 {
|
||||
return 0.0
|
||||
}
|
||||
|
||||
// Precision = total hits / number of queries
|
||||
return float64(ahit) / float64(len(gts))
|
||||
if len(ids) == 0 {
|
||||
return 0.0
|
||||
}
|
||||
|
||||
var totalPrecision float64
|
||||
for _, gtSet := range gtSets {
|
||||
hits := Hit(ids, gtSet)
|
||||
totalPrecision += float64(hits) / float64(len(ids))
|
||||
}
|
||||
|
||||
return totalPrecision / float64(len(gts))
|
||||
}
|
||||
|
||||
@@ -20,14 +20,22 @@ func (r *RecallMetric) Compute(metricInput *types.MetricInput) float64 {
|
||||
|
||||
// Convert ground truth to sets for efficient lookup
|
||||
gtSets := SliceMap(gts, ToSet)
|
||||
// Count total hits across all relevant documents
|
||||
ahit := Fold(gtSets, 0, func(a int, b map[int]struct{}) int { return a + Hit(ids, b) })
|
||||
|
||||
// Handle case with no ground truth
|
||||
if len(gtSets) == 0 {
|
||||
return 0.0
|
||||
}
|
||||
|
||||
// Recall = total hits / total relevant documents
|
||||
return float64(ahit) / float64(len(gtSets))
|
||||
if len(ids) == 0 {
|
||||
return 0.0
|
||||
}
|
||||
|
||||
var totalRecall float64
|
||||
for _, gtSet := range gtSets {
|
||||
hits := Hit(ids, gtSet)
|
||||
if len(gtSet) > 0 {
|
||||
totalRecall += float64(hits) / float64(len(gtSet))
|
||||
}
|
||||
}
|
||||
|
||||
// Recall = average recall across all ground truth sets
|
||||
return totalRecall / float64(len(gtSets))
|
||||
}
|
||||
|
||||
@@ -648,7 +648,7 @@ func (h *SystemHandler) checkMinio(c *gin.Context, ctx context.Context, cfg *typ
|
||||
|
||||
if cfg.Mode == "remote" {
|
||||
if blocked, reason := isBlockedStorageEndpoint(endpoint); blocked {
|
||||
logger.Warnf(ctx, "Storage check: MinIO endpoint blocked by SSRF protection endpoint=%s", endpoint)
|
||||
logger.Warnf(ctx, "Storage check: MinIO endpoint blocked by SSRF protection, endpoint: %s", endpoint)
|
||||
c.JSON(200, gin.H{"code": 0, "data": StorageCheckResponse{OK: false, Message: reason}})
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user