diff options
| author | Paul Buetow <paul@buetow.org> | 2026-04-22 08:29:14 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-04-22 08:29:14 +0300 |
| commit | 15639ba3508ab92599bd1884ba07139c73b2dac0 (patch) | |
| tree | 7b6bfaaf8b76827307c62ae5fa461f7920d08140 /internal/comic/artist.go | |
| parent | af21fec32c7cf3c15879dba6646a0b5cf19ac583 (diff) | |
Add manual prompt image mode
Diffstat (limited to 'internal/comic/artist.go')
| -rw-r--r-- | internal/comic/artist.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/internal/comic/artist.go b/internal/comic/artist.go index b089769..13826ee 100644 --- a/internal/comic/artist.go +++ b/internal/comic/artist.go @@ -210,12 +210,22 @@ func (a *Artist) renderPage(ctx context.Context, fileName, templateName string, } func (a *Artist) generateWithRetry(ctx context.Context, prompt, outputFile, label string, refs [][]byte) error { + return a.generateWithRetryAndValidation(ctx, prompt, outputFile, label, refs, validateImagePromptLeakageFn) +} + +func (a *Artist) generatePromptImage(ctx context.Context, prompt, outputFile string) error { + return a.generateWithRetryAndValidation(ctx, prompt, outputFile, "manual prompt image", nil, nil) +} + +type imageOutputValidator func(context.Context, string, string, string) error + +func (a *Artist) generateWithRetryAndValidation(ctx context.Context, prompt, outputFile, label string, refs [][]byte, validator imageOutputValidator) error { attempts := a.pageMaxRetries for attempt := 1; attempt <= attempts; attempt++ { callCtx, cancel := withTimeout(ctx, helperTimeout) err := a.generateImage(callCtx, prompt, outputFile, refs) - if err == nil { - if leakErr := validateImagePromptLeakageFn(callCtx, outputFile, label, a.script); leakErr != nil { + if err == nil && validator != nil { + if leakErr := validator(callCtx, outputFile, label, a.script); leakErr != nil { _ = os.Remove(outputFile) err = leakErr } |
