summaryrefslogtreecommitdiff
path: root/internal/image
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-07-17 15:35:03 +0300
committerPaul Buetow <paul@buetow.org>2025-07-17 15:35:03 +0300
commitf6477f82dc79d17e9ee3193c81dca2db884a7119 (patch)
tree3424d2342ba976791dc3bb8b108dfdd290018175 /internal/image
parent094447b570c5c5a7c751e0e60279cfa08e945755 (diff)
add phoenetic alphabet
Diffstat (limited to 'internal/image')
-rw-r--r--internal/image/openai.go21
-rw-r--r--internal/image/search.go1
2 files changed, 16 insertions, 6 deletions
diff --git a/internal/image/openai.go b/internal/image/openai.go
index ac66a45..c00ae5a 100644
--- a/internal/image/openai.go
+++ b/internal/image/openai.go
@@ -115,12 +115,21 @@ func (c *OpenAIClient) Search(ctx context.Context, opts *SearchOptions) ([]Searc
}
}
- // Translate Bulgarian word to English for better results
- translatedWord, err := c.translateBulgarianToEnglish(ctx, opts.Query)
- if err != nil {
- // If translation fails, fall back to using the original word
- fmt.Printf("Translation failed: %v, using original word\n", err)
- translatedWord = opts.Query
+ // Use provided translation if available, otherwise translate Bulgarian word to English
+ var translatedWord string
+ if opts.Translation != "" {
+ // Use the translation that was already provided (from UI or user input)
+ translatedWord = opts.Translation
+ fmt.Printf("Using provided translation: %s -> %s\n", opts.Query, translatedWord)
+ } else {
+ // Translate Bulgarian word to English for better results
+ var err error
+ translatedWord, err = c.translateBulgarianToEnglish(ctx, opts.Query)
+ if err != nil {
+ // If translation fails, fall back to using the original word
+ fmt.Printf("Translation failed: %v, using original word\n", err)
+ translatedWord = opts.Query
+ }
}
// Create prompt - use custom if provided, otherwise generate educational prompt
diff --git a/internal/image/search.go b/internal/image/search.go
index 800a114..540e0a1 100644
--- a/internal/image/search.go
+++ b/internal/image/search.go
@@ -20,6 +20,7 @@ type SearchResult struct {
// SearchOptions configures the image search
type SearchOptions struct {
Query string // Search query (Bulgarian word)
+ Translation string // English translation (if already available)
Language string // Language code (default: "bg")
SafeSearch bool // Enable safe search filtering
PerPage int // Number of results per page