This reverts commit 6faff4d269.
This commit is contained in:
@@ -306,7 +306,6 @@ User query: ` + query,
|
||||
},
|
||||
"generationConfig": map[string]any{
|
||||
"responseMimeType": "application/json",
|
||||
"maxOutputTokens": 1400,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -213,18 +213,3 @@ func TestMergeRecommendationsExcludesIrrelevantAndPendingFiller(t *testing.T) {
|
||||
t.Fatalf("unexpected merged result: %#v", merged)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterHardGeminiErrorsIgnoresLowValueVisualFailures(t *testing.T) {
|
||||
errs := []string{
|
||||
"candidate thumbnail is low value",
|
||||
"no candidate thumbnails or preview frames could be fetched for gemini vision",
|
||||
"gemini vision JSON extraction failed: no complete JSON object found",
|
||||
}
|
||||
filtered := filterHardGeminiErrors(errs)
|
||||
if len(filtered) != 1 {
|
||||
t.Fatalf("expected only hard errors to remain, got %#v", filtered)
|
||||
}
|
||||
if !strings.Contains(filtered[0], "JSON extraction failed") {
|
||||
t.Fatalf("unexpected filtered errors: %#v", filtered)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ func EvaluateAllCandidatesWithGemini(service *GeminiService, query string, ranke
|
||||
}
|
||||
|
||||
func EvaluateAllCandidatesWithGeminiWithDeadline(service *GeminiService, query string, ranked []SearchResult, deadline time.Time) ([]AIRecommendation, GeminiBatchStats, error) {
|
||||
const chunkSize = 6
|
||||
const chunkSize = 8
|
||||
const maxConcurrentBatches = 2
|
||||
if service == nil {
|
||||
return nil, GeminiBatchStats{}, fmt.Errorf("gemini service is not configured")
|
||||
@@ -187,7 +187,6 @@ func EvaluateAllCandidatesWithGeminiWithDeadline(service *GeminiService, query s
|
||||
})
|
||||
}
|
||||
recovered, recoveredErrs := recoverGeminiBatchSequentially(service, query, ranked, batch.index*chunkSize)
|
||||
hardErrs := filterHardGeminiErrors(recoveredErrs)
|
||||
if len(recovered) > 0 {
|
||||
stats.SequentialRetried++
|
||||
stats.Succeeded++
|
||||
@@ -198,9 +197,9 @@ func EvaluateAllCandidatesWithGeminiWithDeadline(service *GeminiService, query s
|
||||
seen[item.Link] = true
|
||||
merged = append(merged, item)
|
||||
}
|
||||
if len(hardErrs) > 0 {
|
||||
if len(recoveredErrs) > 0 {
|
||||
stats.Failed++
|
||||
for _, recoveredErr := range hardErrs {
|
||||
for _, recoveredErr := range recoveredErrs {
|
||||
if len(stats.Errors) < 5 {
|
||||
stats.Errors = append(stats.Errors, recoveredErr)
|
||||
}
|
||||
@@ -208,9 +207,6 @@ func EvaluateAllCandidatesWithGeminiWithDeadline(service *GeminiService, query s
|
||||
}
|
||||
continue
|
||||
}
|
||||
if len(hardErrs) == 0 {
|
||||
continue
|
||||
}
|
||||
stats.Failed++
|
||||
if len(stats.Errors) < 5 {
|
||||
stats.Errors = append(stats.Errors, batch.err.Error())
|
||||
@@ -333,35 +329,6 @@ func MergeUniqueRecommendations(base, extra []AIRecommendation) []AIRecommendati
|
||||
return merged
|
||||
}
|
||||
|
||||
func filterHardGeminiErrors(errs []string) []string {
|
||||
filtered := make([]string, 0, len(errs))
|
||||
for _, item := range errs {
|
||||
if isIgnorableGeminiError(item) {
|
||||
continue
|
||||
}
|
||||
filtered = append(filtered, item)
|
||||
}
|
||||
return filtered
|
||||
}
|
||||
|
||||
func isIgnorableGeminiError(message string) bool {
|
||||
lower := strings.ToLower(strings.TrimSpace(message))
|
||||
if lower == "" {
|
||||
return false
|
||||
}
|
||||
for _, token := range []string{
|
||||
"no candidate thumbnails or preview frames could be fetched for gemini vision",
|
||||
"candidate thumbnail is low value",
|
||||
"candidate has no thumbnail or preview video",
|
||||
"image url is empty",
|
||||
} {
|
||||
if strings.Contains(lower, token) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func MergeGeminiBatchStats(base, extra GeminiBatchStats) GeminiBatchStats {
|
||||
merged := base
|
||||
merged.CandidateCap += extra.CandidateCap
|
||||
|
||||
Reference in New Issue
Block a user