diff options
| author | Paul Buetow <paul@buetow.org> | 2025-07-21 16:34:16 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-07-21 16:34:16 +0300 |
| commit | 18390dc18f397207e6eb8e67991dc7078b5e7515 (patch) | |
| tree | 75a5b4862346adebe6616ef157c94b9b00cac6fb /internal/image | |
| parent | f3e301168ad742a556b336761e28f739eb1d7143 (diff) | |
more on this
Diffstat (limited to 'internal/image')
| -rw-r--r-- | internal/image/openai.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/internal/image/openai.go b/internal/image/openai.go index 637b8a1..d964b55 100644 --- a/internal/image/openai.go +++ b/internal/image/openai.go @@ -23,6 +23,9 @@ type OpenAIClient struct { quality string // standard or hd (dall-e-3 only) style string // natural or vivid (dall-e-3 only) lastPrompt string // Store the last used prompt for attribution + + // PromptCallback is called when the prompt is generated, before the image is created + PromptCallback func(prompt string) } // OpenAIConfig holds configuration for the OpenAI image provider @@ -120,6 +123,11 @@ func (c *OpenAIClient) Search(ctx context.Context, opts *SearchOptions) ([]Searc // Store the prompt for attribution c.lastPrompt = prompt + // Call the callback if set + if c.PromptCallback != nil { + c.PromptCallback(prompt) + } + // Log the prompt to stdout for debugging fmt.Printf("OpenAI Image Generation Prompt (%d chars): %s\n", len(prompt), prompt) fmt.Printf("OpenAI Image Generation: Using model '%s' with size '%s'\n", c.model, c.size) @@ -220,6 +228,11 @@ func (c *OpenAIClient) GetLastPrompt() string { return c.lastPrompt } +// SetPromptCallback sets a callback function that will be called when the prompt is generated +func (c *OpenAIClient) SetPromptCallback(callback func(prompt string)) { + c.PromptCallback = callback +} + // createEducationalPrompt generates a prompt optimized for language learning func (c *OpenAIClient) createEducationalPrompt(bulgarianWord, englishTranslation string) string { // Generate a scene description for the word |
