fix: use OCI title annotation for virtual path in GGUF layer extraction

Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
This commit is contained in:
Christopher Phillips 2025-11-13 01:43:54 -05:00
parent 80319572cf
commit ec978f01c5
No known key found for this signature in database
3 changed files with 13 additions and 2 deletions

5
go.mod
View File

@ -286,7 +286,10 @@ require (
modernc.org/memory v1.11.0 // indirect
)
require github.com/gpustack/gguf-parser-go v0.22.1
require (
github.com/cespare/xxhash/v2 v2.3.0
github.com/gpustack/gguf-parser-go v0.22.1
)
require (
cyphar.com/go-pathrs v0.2.1 // indirect

1
go.sum
View File

@ -229,7 +229,6 @@ github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqy
github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=

View File

@ -178,6 +178,15 @@ func (r *ociModelResolver) cleanup() error {
// extractVirtualPath generates a virtual path for a GGUF layer.
// This simulates where the file would be in the artifact.
func extractVirtualPath(layerIndex int, annotations map[string]string) string {
// Check if there's a title annotation that specifies the filename
if title, ok := annotations["org.opencontainers.image.title"]; ok && title != "" {
// Ensure it starts with /
if !strings.HasPrefix(title, "/") {
return "/" + title
}
return title
}
// Fall back to default naming
return fmt.Sprintf("/model-layer-%d.gguf", layerIndex)
}