feat(imagegen): optional per-request generation settings
CI / Tidy (pull_request) Successful in 9m27s
CI / Build & Test (pull_request) Successful in 9m47s

Add Steps, CFGScale, NegativePrompt, Sampler, Seed to imagegen.Request
(pointer/empty = leave the backend's per-model default), with mirror
options, and forward them in the llamaswap wire payload as the
stable-diffusion.cpp fields (steps/cfg_scale/negative_prompt/
sample_method/seed). Unset fields are omitted so sd-server keeps its
baked defaults.

Lets callers (e.g. mort drawbots) override only what they explicitly set.
This commit is contained in:
2026-06-28 17:57:19 -04:00
parent 8b924700fb
commit a744cdc335
4 changed files with 111 additions and 7 deletions
+21 -7
View File
@@ -27,14 +27,23 @@ type imageModel struct {
id string
}
// imageRequest is the OpenAI /v1/images/generations request shape. We always
// request b64_json so the bytes come back inline (no second fetch).
// imageRequest is the OpenAI /v1/images/generations request shape, plus the
// stable-diffusion.cpp extras llama-swap forwards to sd-server. We always
// request b64_json so the bytes come back inline (no second fetch). The
// optional fields are pointers/omitempty so an unset value is omitted entirely
// and sd-server falls back to the model's own default (a field name a given
// sd-server build doesn't recognize is simply ignored — harmless).
type imageRequest struct {
Model string `json:"model"`
Prompt string `json:"prompt"`
N int `json:"n,omitempty"`
Size string `json:"size,omitempty"`
ResponseFormat string `json:"response_format"`
Model string `json:"model"`
Prompt string `json:"prompt"`
N int `json:"n,omitempty"`
Size string `json:"size,omitempty"`
ResponseFormat string `json:"response_format"`
Steps *int `json:"steps,omitempty"`
CFGScale *float64 `json:"cfg_scale,omitempty"`
NegativePrompt string `json:"negative_prompt,omitempty"`
SampleMethod string `json:"sample_method,omitempty"`
Seed *int64 `json:"seed,omitempty"`
}
type imageResponse struct {
@@ -61,6 +70,11 @@ func (m *imageModel) Generate(ctx context.Context, req imagegen.Request, opts ..
N: req.N,
Size: req.Size,
ResponseFormat: "b64_json",
Steps: req.Steps,
CFGScale: req.CFGScale,
NegativePrompt: req.NegativePrompt,
SampleMethod: req.Sampler,
Seed: req.Seed,
}
var resp imageResponse