This commit is contained in:
@@ -18,7 +18,6 @@ type GeminiBatchStats struct {
|
||||
Failed int `json:"failed"`
|
||||
SequentialRetried int `json:"sequentialRetried"`
|
||||
RecommendedCount int `json:"recommendedCount"`
|
||||
TimedOut bool `json:"timedOut,omitempty"`
|
||||
Errors []string `json:"errors,omitempty"`
|
||||
}
|
||||
|
||||
@@ -91,10 +90,6 @@ func GeminiCandidateLimit(total int) int {
|
||||
}
|
||||
|
||||
func EvaluateAllCandidatesWithGemini(service *GeminiService, query string, ranked []SearchResult) ([]AIRecommendation, GeminiBatchStats, error) {
|
||||
return EvaluateAllCandidatesWithGeminiBudget(service, query, ranked, time.Time{})
|
||||
}
|
||||
|
||||
func EvaluateAllCandidatesWithGeminiBudget(service *GeminiService, query string, ranked []SearchResult, deadline time.Time) ([]AIRecommendation, GeminiBatchStats, error) {
|
||||
if service == nil {
|
||||
return nil, GeminiBatchStats{}, fmt.Errorf("gemini service is not configured")
|
||||
}
|
||||
@@ -112,10 +107,6 @@ func EvaluateAllCandidatesWithGeminiBudget(service *GeminiService, query string,
|
||||
merged := make([]AIRecommendation, 0, len(ranked))
|
||||
seen := map[string]bool{}
|
||||
for idx := 0; idx < limit; idx++ {
|
||||
if !deadline.IsZero() && time.Now().After(deadline) {
|
||||
stats.TimedOut = true
|
||||
break
|
||||
}
|
||||
recommendations, err := recoverGeminiCandidateSequentially(service, query, ranked[idx])
|
||||
if err != nil {
|
||||
stats.Failed++
|
||||
@@ -140,10 +131,6 @@ func EvaluateAllCandidatesWithGeminiBudget(service *GeminiService, query string,
|
||||
stats.RecommendedCount = len(merged)
|
||||
|
||||
switch {
|
||||
case stats.TimedOut && len(merged) > 0:
|
||||
return merged, stats, fmt.Errorf("gemini vision evaluation stopped early to avoid request timeout")
|
||||
case stats.TimedOut && len(merged) == 0:
|
||||
return nil, stats, fmt.Errorf("gemini vision evaluation timed out before any usable results were returned")
|
||||
case len(merged) > 0 && stats.Failed == 0:
|
||||
return merged, stats, nil
|
||||
case len(merged) > 0 && stats.Failed > 0:
|
||||
|
||||
Reference in New Issue
Block a user