This commit is contained in:
+26
-2
@@ -467,7 +467,7 @@ func (a *App) searchMedia(c *gin.Context) {
|
||||
supplementalDeadlineLimited := false
|
||||
if services.NeedsSupplementalExploration(recommended) && time.Now().Before(deadline.Add(-10*time.Second)) {
|
||||
a.Hub.Broadcast("progress", gin.H{"type": "search", "status": "Gemini 평가가 약해 추가 후보를 탐색하는 중", "progress": 82})
|
||||
explorationQueries := buildSupplementalQueries(req.Query, queryVariants)
|
||||
explorationQueries := buildSupplementalQueries(a.GeminiService, req.Query, queryVariants, recommended)
|
||||
extraResults, extraMeta, extraErr := a.SearchService.SearchMediaWithDeadline(explorationQueries, enabledPlatforms, deadline.Add(-10*time.Second))
|
||||
supplementalDeadlineLimited = extraMeta.PartialDueToDeadline
|
||||
if extraErr == nil && len(extraResults) > 0 {
|
||||
@@ -613,15 +613,39 @@ func selectedPlatformLabel(platforms map[string]bool) string {
|
||||
return strings.Join(labels, ", ")
|
||||
}
|
||||
|
||||
func buildSupplementalQueries(query string, existing []string) []string {
|
||||
func buildSupplementalQueries(service *services.GeminiService, query string, existing []string, reviewed []services.AIRecommendation) []string {
|
||||
if service != nil {
|
||||
if generated, err := service.BuildSupplementalQueries(query, existing, reviewed); err == nil && len(generated) > 0 {
|
||||
return mergeSupplementalQuerySets(existing, generated)
|
||||
}
|
||||
}
|
||||
return buildDeterministicSupplementalQueries(query, existing, reviewed)
|
||||
}
|
||||
|
||||
func buildDeterministicSupplementalQueries(query string, existing []string, reviewed []services.AIRecommendation) []string {
|
||||
candidates := append([]string{}, existing...)
|
||||
for _, item := range reviewed {
|
||||
if item.Assessment == "positive" && item.SearchHint != "" {
|
||||
candidates = append(candidates, item.SearchHint)
|
||||
}
|
||||
if (item.Assessment == "unclear" || services.IsExcludedAssessment(item.Assessment)) && item.SearchHint != "" {
|
||||
candidates = append(candidates, query+" "+item.SearchHint)
|
||||
}
|
||||
}
|
||||
candidates = append(candidates,
|
||||
query+" cinematic stock footage",
|
||||
query+" editorial b-roll",
|
||||
query+" establishing shot",
|
||||
query+" drone footage",
|
||||
query+" authentic candid couple",
|
||||
query+" urban park lifestyle footage",
|
||||
)
|
||||
return mergeSupplementalQuerySets(nil, candidates)
|
||||
}
|
||||
|
||||
func mergeSupplementalQuerySets(base, extra []string) []string {
|
||||
candidates := append([]string{}, base...)
|
||||
candidates = append(candidates, extra...)
|
||||
seen := map[string]bool{}
|
||||
result := make([]string, 0, len(candidates))
|
||||
for _, item := range candidates {
|
||||
|
||||
Reference in New Issue
Block a user