Split ingress keys into text/image protocols with Replicate model listing.
CI / docker (push) Successful in 3m38s
CI / docker (push) Successful in 3m38s
Add model input defaults (including prompt), workflow model editing, ingress API docs, and fix img2img image upload filenames for signed URLs. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
package prediction
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/rose_cat707/luminary/internal/model"
|
||||
)
|
||||
|
||||
func TestValidateInputWithDefaultsOverride(t *testing.T) {
|
||||
overrides := map[string]any{"width": float64(768), "steps": float64(30)}
|
||||
out, err := ValidateInputWithDefaults(model.WorkflowTxt2Img, map[string]any{
|
||||
"prompt": "hello",
|
||||
}, overrides)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if out["width"] != 768 && out["width"] != float64(768) {
|
||||
t.Fatalf("width got %#v", out["width"])
|
||||
}
|
||||
if out["steps"] != 30 && out["steps"] != float64(30) {
|
||||
t.Fatalf("steps got %#v", out["steps"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpenAPISchemaUsesModelDefaults(t *testing.T) {
|
||||
schema := OpenAPISchemaForWorkflow(model.WorkflowTxt2Img, "flux", "desc", map[string]any{
|
||||
"width": float64(768),
|
||||
})
|
||||
components := schema["components"].(map[string]any)
|
||||
schemas := components["schemas"].(map[string]any)
|
||||
input := schemas["Input"].(map[string]any)
|
||||
props := input["properties"].(map[string]any)
|
||||
width := props["width"].(map[string]any)
|
||||
if width["default"] != float64(768) {
|
||||
t.Fatalf("unexpected width default %#v", width["default"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateInputPromptDefault(t *testing.T) {
|
||||
overrides := map[string]any{"prompt": "a scenic landscape"}
|
||||
out, err := ValidateInputWithDefaults(model.WorkflowTxt2Img, map[string]any{}, overrides)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if out["prompt"] != "a scenic landscape" {
|
||||
t.Fatalf("prompt got %#v", out["prompt"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateInputRequiredWithoutDefault(t *testing.T) {
|
||||
_, err := ValidateInputWithDefaults(model.WorkflowTxt2Img, map[string]any{}, map[string]any{})
|
||||
if err == nil {
|
||||
t.Fatal("expected missing prompt error")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user