50 lines
1.1 KiB
Go
50 lines
1.1 KiB
Go
|
|
//go:build ignore
|
||
|
|
|
||
|
|
package main
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"fmt"
|
||
|
|
"os"
|
||
|
|
|
||
|
|
"gen2d/internal/config"
|
||
|
|
"gen2d/internal/service"
|
||
|
|
)
|
||
|
|
|
||
|
|
func main() {
|
||
|
|
cfg := config.Load()
|
||
|
|
|
||
|
|
// 清空 API key 强制走 mock
|
||
|
|
cfg.ImageGen.APIKey = ""
|
||
|
|
service.InitImageGenConfig(cfg.ImageGen)
|
||
|
|
service.InitLLMConfig(cfg.LLM)
|
||
|
|
|
||
|
|
in := service.PipelineInput{
|
||
|
|
AssetType: "sprite",
|
||
|
|
Prompt: "a cute cat warrior with golden armor",
|
||
|
|
Tags: []string{"pixel art", "fantasy", "16-bit"},
|
||
|
|
Params: service.AssetParams{
|
||
|
|
Resolution: 816,
|
||
|
|
Frames: service.FrameParams{Directions: 4, FramesPerDirection: 1},
|
||
|
|
Format: "individual",
|
||
|
|
},
|
||
|
|
}
|
||
|
|
|
||
|
|
output, err := service.RunPipeline(context.Background(), in)
|
||
|
|
if err != nil {
|
||
|
|
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||
|
|
os.Exit(1)
|
||
|
|
}
|
||
|
|
|
||
|
|
os.MkdirAll("test_output", 0755)
|
||
|
|
for i, a := range output.Assets {
|
||
|
|
fname := fmt.Sprintf("test_output/gen_%d.%s", i, a.Format)
|
||
|
|
if err := os.WriteFile(fname, a.Data, 0644); err != nil {
|
||
|
|
fmt.Fprintf(os.Stderr, "write %s: %v\n", fname, err)
|
||
|
|
os.Exit(1)
|
||
|
|
}
|
||
|
|
fmt.Printf("saved %s (%d bytes)\n", fname, len(a.Data))
|
||
|
|
}
|
||
|
|
fmt.Printf("metadata: %+v\n", output.Metadata)
|
||
|
|
}
|