Files
fn_registry/functions/ml/genconfig_json_marshal.go
egutierrez e3c8979e8d chore: auto-commit (95 archivos)
- cmd/fn/doctor.go
- cmd/fn/main.go
- cpp/apps/primitives_gallery/playground/tables/CMakeLists.txt
- cpp/apps/primitives_gallery/playground/tables/data_table.cpp
- cpp/apps/primitives_gallery/playground/tables/data_table_logic.cpp
- cpp/apps/primitives_gallery/playground/tables/data_table_logic.h
- cpp/apps/primitives_gallery/playground/tables/self_test.cpp
- cpp/apps/primitives_gallery/playground/tables/tql.cpp
- cpp/apps/primitives_gallery/playground/tables/viz.cpp
- cpp/apps/primitives_gallery/playground/tables/viz.h
- ...

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 00:50:34 +02:00

21 lines
775 B
Go

package ml
import "encoding/json"
// GenconfigMarshal serializa un GenerationConfig a JSON canonico con indent de 2 espacios.
// El formato es identico al de Python json.dumps(indent=2, sort_keys=False):
// keys en el orden de declaracion del struct, snake_case, campos omitempty ausentes si zero.
func GenconfigMarshal(cfg GenerationConfig) ([]byte, error) {
return json.MarshalIndent(cfg, "", " ")
}
// GenconfigUnmarshal deserializa JSON (compacto o con indent) a GenerationConfig.
// Los campos JSON deben usar snake_case: negative_prompt, cfg_scale, model_type, etc.
func GenconfigUnmarshal(data []byte) (GenerationConfig, error) {
var cfg GenerationConfig
if err := json.Unmarshal(data, &cfg); err != nil {
return GenerationConfig{}, err
}
return cfg, nil
}