feat(imagegen): optional per-request generation settings
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user