Files
fn_registry/functions/ml/sdcli_resolve_binary.md
T
egutierrez 8284afcba5 feat(ml): auto-commit con 14 cambios
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 01:22:02 +02:00

2.0 KiB

name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
name kind lang domain version purity signature description tags uses_functions uses_types returns returns_optional error_type imports params output tested tests test_file_path file_path
sdcli_resolve_binary function go ml 1.0.0 impure func SdcliResolveBinary(hint string) (SdcliBinary, error) Localiza el binario sd / sd-cli de stable-diffusion.cpp. Busca en orden: hint explicito, LookPath('sd'), LookPath('sd-cli'). Detecta la version ejecutando --version con timeout 3s. Retorna SdcliBinary con path, version y fuente de resolucion.
ml
sdcli
stablediffusion
binary
subprocess
imagegen
false error_go_core
context
fmt
os
os/exec
strings
time
name desc
hint Path explicito al binario sd. Si es string vacio se busca en PATH. Si no es vacio debe existir y ser ejecutable.
SdcliBinary con Path absoluto, Version detectada (puede ser vacia si --version falla) y Source ('config' si viene de hint, 'path' si viene de LookPath). true
missing binary returns error when PATH empty
hint path resolves to config source
functions/ml/sdcli_test.go functions/ml/sdcli_resolve_binary.go

Ejemplo

// Buscar automaticamente en PATH
bin, err := SdcliResolveBinary("")
if err != nil {
    log.Fatal(err)
}
fmt.Printf("sd found at %s (version: %s)\n", bin.Path, bin.Version)

// Hint explicito (ej. desde config de usuario)
bin, err = SdcliResolveBinary("/opt/stable-diffusion/sd")

Notas

SdcliBinary es el token de resolucion que se pasa a SdcliGenerate. Separar la resolucion de la ejecucion permite validar el binario al arrancar la app sin lanzar una generacion.

La deteccion de version es best-effort: si sd --version no existe o falla, Version queda vacia y no se propaga error. Algunos builds de stable-diffusion.cpp no implementan --version; en ese caso Version == "" es el comportamiento esperado.

Source distingue binarios configurados explicitamente ("config") de los encontrados en PATH ("path"), util para logging y diagnostico.