Principle 1 — Predictable Names: - rocmModel.srv → rocmModel.server (struct field) - recordMetrics: met → metrics (local var) - backend.go/model.go: cfg → config (local vars) - gguf.go: tc/kc → tensorCount32/kvCount32 (v2 count reads) Principle 2 — Comments as Usage Examples: - Added concrete usage examples to all exported functions: VRAMInfo, ModelInfo, DiscoverModels, GetVRAMInfo, ROCmAvailable, LoadModel, Available, NewClient, Health, ChatComplete, Complete, ReadMetadata, FileTypeName Principle 5 — Test naming (_Good/_Bad/_Ugly): - All test functions renamed to AX-7 convention across: discover_test.go, vram_test.go, server_test.go, internal/gguf/gguf_test.go, internal/llamacpp/client_test.go, internal/llamacpp/health_test.go Also: fix go.sum missing entry for dappco.re/go/core transitive dep (pulled in by go-inference replace directive). All tests pass: go test ./... -short -count=1 Co-Authored-By: Virgil <virgil@lethean.io> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
41 lines
980 B
Go
41 lines
980 B
Go
package rocm
|
|
|
|
import (
|
|
"path/filepath"
|
|
|
|
"forge.lthn.ai/core/go-rocm/internal/gguf"
|
|
)
|
|
|
|
// DiscoverModels scans a directory for GGUF model files.
|
|
// Files that cannot be parsed are silently skipped.
|
|
//
|
|
// models, err := rocm.DiscoverModels("/data/lem/gguf")
|
|
// for _, m := range models {
|
|
// fmt.Printf("%s: %s %s ctx=%d\n", m.Name, m.Architecture, m.Quantisation, m.ContextLen)
|
|
// }
|
|
func DiscoverModels(dir string) ([]ModelInfo, error) {
|
|
matches, err := filepath.Glob(filepath.Join(dir, "*.gguf"))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var models []ModelInfo
|
|
for _, path := range matches {
|
|
meta, err := gguf.ReadMetadata(path)
|
|
if err != nil {
|
|
continue
|
|
}
|
|
|
|
models = append(models, ModelInfo{
|
|
Path: path,
|
|
Architecture: meta.Architecture,
|
|
Name: meta.Name,
|
|
Quantisation: gguf.FileTypeName(meta.FileType),
|
|
Parameters: meta.SizeLabel,
|
|
FileSize: meta.FileSize,
|
|
ContextLen: meta.ContextLength,
|
|
})
|
|
}
|
|
|
|
return models, nil
|
|
}
|