This commit is contained in:
@@ -154,7 +154,8 @@ func (g *GeminiService) Recommend(query string, candidates []SearchResult) ([]AI
|
||||
{
|
||||
"text": `Analyze the provided images for the user's search intent. Return JSON only in this shape:
|
||||
{"recommendations":[{"index":0,"reason":"short reason","recommended":true}]}
|
||||
Mark only the best matches as recommended=true. Keep reasons concise. Recommend up to 8 items.
|
||||
Return one entry for every analyzed candidate. Use Korean for every reason. Keep reasons concise but specific enough to explain usefulness.
|
||||
Mark the strongest matches as recommended=true and weaker matches as recommended=false.
|
||||
Prefer cinematic b-roll, stock footage, editorial footage, clean composition, usable establishing shots, and professional media thumbnails.
|
||||
Avoid clickbait faces, exaggerated expressions, meme aesthetics, low-information thumbnails, sensational text overlays, or gossip-style imagery.
|
||||
Favor thumbnails that look directly useful for media editing and footage sourcing.
|
||||
@@ -230,7 +231,7 @@ User query: ` + query,
|
||||
|
||||
recommendations := make([]AIRecommendation, 0, len(parsed.Recommendations))
|
||||
for _, rec := range parsed.Recommendations {
|
||||
if rec.Index < 0 || rec.Index >= len(candidates) || !rec.Recommended {
|
||||
if rec.Index < 0 || rec.Index >= len(candidates) {
|
||||
continue
|
||||
}
|
||||
src := candidates[rec.Index]
|
||||
@@ -241,13 +242,13 @@ User query: ` + query,
|
||||
ThumbnailURL: src.ThumbnailURL,
|
||||
PreviewVideoURL: src.PreviewVideoURL,
|
||||
Source: src.Source,
|
||||
Reason: rec.Reason,
|
||||
Recommended: true,
|
||||
Reason: normalizeKoreanReason(rec.Reason),
|
||||
Recommended: rec.Recommended,
|
||||
})
|
||||
}
|
||||
|
||||
if len(recommendations) == 0 {
|
||||
for _, candidate := range candidates[:min(4, len(candidates))] {
|
||||
for _, candidate := range candidates[:min(8, len(candidates))] {
|
||||
recommendations = append(recommendations, AIRecommendation{
|
||||
Title: candidate.Title,
|
||||
Link: candidate.Link,
|
||||
@@ -255,8 +256,8 @@ User query: ` + query,
|
||||
ThumbnailURL: candidate.ThumbnailURL,
|
||||
PreviewVideoURL: candidate.PreviewVideoURL,
|
||||
Source: candidate.Source,
|
||||
Reason: "Fallback result because Gemini returned no recommended items.",
|
||||
Recommended: true,
|
||||
Reason: "Gemini Vision 평가를 받지 못해 키워드 기준으로 보강된 결과입니다.",
|
||||
Recommended: false,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -412,6 +413,14 @@ func truncateForError(text string, limit int) string {
|
||||
return trimmed[:limit] + "..."
|
||||
}
|
||||
|
||||
func normalizeKoreanReason(reason string) string {
|
||||
trimmed := strings.TrimSpace(reason)
|
||||
if trimmed == "" {
|
||||
return "시각 정보가 제한적이지만 검색 의도와의 관련성을 기준으로 평가했습니다."
|
||||
}
|
||||
return trimmed
|
||||
}
|
||||
|
||||
func buildSearchQueries(originalQuery, englishQuery string) []string {
|
||||
base := strings.TrimSpace(englishQuery)
|
||||
if base == "" {
|
||||
|
||||
Reference in New Issue
Block a user