diff options
Diffstat (limited to 'internal/image')
| -rw-r--r-- | internal/image/openai.go | 21 | ||||
| -rw-r--r-- | internal/image/search.go | 1 |
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 |
