diff options
| author | Paul Buetow <paul@buetow.org> | 2025-07-15 23:42:32 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-07-15 23:42:32 +0300 |
| commit | b105333c061ea165b3b79317415cbb8b9cfb7c75 (patch) | |
| tree | c2682cc156c372d85ab52d514df4316ceda9071d /internal/image | |
| parent | 61529facc2c5321de9f0ab9123cb1de25bcab62c (diff) | |
feat: add English translations and detailed attribution files
- Automatic Bulgarian to English translation for all words
- Save translations to separate _translation.txt files
- Include translations in Anki CSV export
- Add detailed attribution files for audio and images:
- Audio: model, voice, speed, instructions, processed text
- Image: model, size, quality, style, full prompt used
- Expand image styles to 42 different options (including superhero comic, yoga, etc.)
- Improve image prompts to strongly avoid text generation
- Fix image overwrite issue - now overwrites existing files instead of failing
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'internal/image')
| -rw-r--r-- | internal/image/openai.go | 62 |
1 files changed, 57 insertions, 5 deletions
diff --git a/internal/image/openai.go b/internal/image/openai.go index ee05c80..c4b2e9d 100644 --- a/internal/image/openai.go +++ b/internal/image/openai.go @@ -11,6 +11,7 @@ import ( "os" "path/filepath" "strings" + "time" "github.com/sashabaranov/go-openai" ) @@ -25,6 +26,7 @@ type OpenAIClient struct { style string // natural or vivid (dall-e-3 only) cacheDir string enableCache bool + lastPrompt string // Store the last used prompt for attribution } // OpenAIConfig holds configuration for the OpenAI image provider @@ -124,6 +126,9 @@ func (c *OpenAIClient) Search(ctx context.Context, opts *SearchOptions) ([]Searc // Create educational prompt prompt := c.createEducationalPrompt(opts.Query, translatedWord) + // Store the prompt for attribution + c.lastPrompt = prompt + // Log the prompt to stdout for debugging fmt.Printf("OpenAI Image Generation Prompt: %s\n", prompt) fmt.Printf("OpenAI Image Generation: Using model '%s' with size '%s'\n", c.model, c.size) @@ -221,7 +226,16 @@ func (c *OpenAIClient) Download(ctx context.Context, url string) (io.ReadCloser, // GetAttribution returns the required attribution text func (c *OpenAIClient) GetAttribution(result *SearchResult) string { - return "Image generated by OpenAI DALL-E" + attribution := fmt.Sprintf("Image generated by OpenAI DALL-E\n\n") + attribution += fmt.Sprintf("Model: %s\n", c.model) + attribution += fmt.Sprintf("Size: %s\n", c.size) + if c.model == "dall-e-3" { + attribution += fmt.Sprintf("Quality: %s\n", c.quality) + attribution += fmt.Sprintf("Style: %s\n", c.style) + } + attribution += fmt.Sprintf("\nPrompt used:\n%s\n", c.lastPrompt) + attribution += fmt.Sprintf("\nGenerated at: %s\n", time.Now().Format("2006-01-02 15:04:05")) + return attribution } // Name returns the name of the provider @@ -231,8 +245,9 @@ func (c *OpenAIClient) Name() string { // createEducationalPrompt generates a prompt optimized for language learning func (c *OpenAIClient) createEducationalPrompt(bulgarianWord, englishTranslation string) string { - // Define different art styles for variety + // Define different art styles for variety (42 styles total) styles := []string{ + // Original styles (1-10) "photorealistic, high quality photograph", "detailed digital illustration, clean vector art style", "vibrant cartoon style, animated movie quality", @@ -243,9 +258,46 @@ func (c *OpenAIClient) createEducationalPrompt(bulgarianWord, englishTranslation "oil painting, classical art style", "paper cut art, layered craft style", "isometric illustration, technical drawing style", - "superhero comic book style, dynamic action pose, bold colors", - "yoga/wellness illustration style, peaceful zen aesthetic", + + // Requested styles (11-13) + "superhero comic book style, dynamic action pose, bold colors, Marvel/DC aesthetic", + "super-realistic person practicing yoga, serene wellness photography", "cute illustration with cats interacting with the subject, whimsical cat-themed", + + // Additional artistic styles (14-25) + "impressionist painting style, Monet-inspired brushstrokes", + "art nouveau style, decorative organic forms, Mucha-inspired", + "pop art style, Andy Warhol inspired, bold contrasting colors", + "Japanese ukiyo-e woodblock print style, traditional aesthetic", + "steampunk illustration, Victorian era mechanical elements", + "cyberpunk neon aesthetic, futuristic digital art", + "medieval illuminated manuscript style, gold leaf details", + "graffiti street art style, urban spray paint aesthetic", + "stained glass window art, cathedral-inspired design", + "mosaic tile art style, Byzantine-inspired patterns", + "art deco style, geometric patterns, 1920s aesthetic", + "surrealist style, Salvador Dali inspired dreamlike quality", + + // Photography styles (26-32) + "macro photography style, extreme close-up detail", + "vintage polaroid photograph, retro instant camera aesthetic", + "film noir style, dramatic black and white photography", + "golden hour photography, warm sunset lighting", + "underwater photography style, ethereal aquatic atmosphere", + "aerial drone photography, bird's eye view perspective", + "long exposure photography, motion blur effects", + + // Modern digital styles (33-42) + "vaporwave aesthetic, 80s-90s retro digital art", + "low poly 3D art style, geometric simplified forms", + "pixel art style, 8-bit retro video game aesthetic", + "glitch art style, digital distortion effects", + "double exposure photography, artistic overlay effect", + "tilt-shift photography, miniature world effect", + "infrared photography style, otherworldly color palette", + "holographic iridescent style, rainbow prismatic effects", + "origami paper folding art style, geometric paper craft", + "chalk art style, sidewalk drawing aesthetic", } // Select a random style @@ -258,7 +310,7 @@ func (c *OpenAIClient) createEducationalPrompt(bulgarianWord, englishTranslation "This is for the Bulgarian word '%s' which means %s. "+ "The image should be educational and suitable for language learning flashcards. "+ "Requirements: single main subject, plain background, clear and recognizable. "+ - "No text, labels, or writing in the image.", + "IMPORTANT: No text whatsoever. Do not include any words, letters, typography, labels, captions, or writing of any kind. Image only, without any text elements.", selectedStyle, englishTranslation, bulgarianWord, englishTranslation, ) } |
