1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
package image
import (
"crypto/md5"
"encoding/hex"
"fmt"
"strings"
"time"
)
func (c *GeminiProvider) generateImageID(word string) string {
hash := md5.Sum([]byte(word))
return hex.EncodeToString(hash[:])[:8]
}
func (c *GeminiProvider) buildAttribution(result *SearchResult, prompt string) string {
if result == nil {
return ""
}
var attribution strings.Builder
attribution.WriteString("Image generated by Google Gemini Nano Banana\n\n")
fmt.Fprintf(&attribution, "Model: %s\n", c.modelName())
fmt.Fprintf(&attribution, "Text model: %s\n", c.textModelName())
fmt.Fprintf(&attribution, "Aspect ratio: %s\n", geminiAspectRatio)
fmt.Fprintf(&attribution, "Size: %dx%d\n", result.Width, result.Height)
if result.Description != "" {
fmt.Fprintf(&attribution, "Result: %s\n", result.Description)
}
fmt.Fprintf(&attribution, "\nPrompt used:\n%s\n", prompt)
fmt.Fprintf(&attribution, "\nGenerated at: %s\n", time.Now().Format("2006-01-02 15:04:05"))
return attribution.String()
}
|