This commit is contained in:
+20
-2
@@ -351,6 +351,14 @@ func min(a, b int) int {
|
|||||||
|
|
||||||
func rankSearchResults(query string, results []services.SearchResult) []services.SearchResult {
|
func rankSearchResults(query string, results []services.SearchResult) []services.SearchResult {
|
||||||
queryTerms := strings.Fields(strings.ToLower(query))
|
queryTerms := strings.Fields(strings.ToLower(query))
|
||||||
|
positiveTerms := []string{
|
||||||
|
"b-roll", "b roll", "stock", "stock footage", "footage", "cinematic", "editorial",
|
||||||
|
"establishing", "4k", "hd", "drone", "ambient", "scene", "urban", "cityscape",
|
||||||
|
}
|
||||||
|
negativeTerms := []string{
|
||||||
|
"shocking", "amazing", "crazy", "must watch", "reaction", "gossip", "celebrity",
|
||||||
|
"thumbnail", "meme", "prank", "drama", "breaking", "viral",
|
||||||
|
}
|
||||||
type scoredResult struct {
|
type scoredResult struct {
|
||||||
item services.SearchResult
|
item services.SearchResult
|
||||||
score int
|
score int
|
||||||
@@ -365,6 +373,16 @@ func rankSearchResults(query string, results []services.SearchResult) []services
|
|||||||
score += 3
|
score += 3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for _, term := range positiveTerms {
|
||||||
|
if strings.Contains(text, term) {
|
||||||
|
score += 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, term := range negativeTerms {
|
||||||
|
if strings.Contains(text, term) {
|
||||||
|
score -= 4
|
||||||
|
}
|
||||||
|
}
|
||||||
if result.ThumbnailURL != "" {
|
if result.ThumbnailURL != "" {
|
||||||
score += 2
|
score += 2
|
||||||
}
|
}
|
||||||
@@ -372,9 +390,9 @@ func rankSearchResults(query string, results []services.SearchResult) []services
|
|||||||
case "Google Video":
|
case "Google Video":
|
||||||
score += 3
|
score += 3
|
||||||
case "Envato":
|
case "Envato":
|
||||||
score += 2
|
score += 4
|
||||||
case "Artgrid":
|
case "Artgrid":
|
||||||
score += 2
|
score += 4
|
||||||
}
|
}
|
||||||
scored = append(scored, scoredResult{item: result, score: score})
|
scored = append(scored, scoredResult{item: result, score: score})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,8 +48,12 @@ func (g *GeminiService) ExpandQuery(query string) ([]string, error) {
|
|||||||
"parts": []map[string]string{
|
"parts": []map[string]string{
|
||||||
{
|
{
|
||||||
"text": `Return JSON only in this shape: {"querywords":["..."]}.
|
"text": `Return JSON only in this shape: {"querywords":["..."]}.
|
||||||
Generate at most 4 concise search variations for media discovery across Google Video, Envato, and Artgrid.
|
Generate at most 10 concise search variations for media discovery across Google Video, Envato, and Artgrid.
|
||||||
Keep the original language when possible. User query: ` + query,
|
If the user query is in Korean, include strong English search variants that a stock footage editor would use.
|
||||||
|
Prioritize media, video footage, stock footage, cinematic b-roll, editorial footage, and scene-based search terms.
|
||||||
|
Avoid celebrity gossip, reaction-style phrasing, clickbait phrasing, and generic web search wording.
|
||||||
|
Mix Korean and English when useful, but make sure several queries are clean English production keywords.
|
||||||
|
User query: ` + query,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -57,7 +61,7 @@ Keep the original language when possible. User query: ` + query,
|
|||||||
"generationConfig": map[string]any{
|
"generationConfig": map[string]any{
|
||||||
"responseMimeType": "application/json",
|
"responseMimeType": "application/json",
|
||||||
"temperature": 0.2,
|
"temperature": 0.2,
|
||||||
"maxOutputTokens": 120,
|
"maxOutputTokens": 220,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,7 +129,11 @@ 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:
|
"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}]}
|
{"recommendations":[{"index":0,"reason":"short reason","recommended":true}]}
|
||||||
Mark only the best matches as recommended=true. Keep reasons concise. Recommend up to 8 items. User query: ` + query,
|
Mark only the best matches as recommended=true. Keep reasons concise. Recommend up to 8 items.
|
||||||
|
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.
|
||||||
|
User query: ` + query,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user