@@ -33,6 +33,7 @@ import (
3333
3434 modelspec "github.com/CloudNativeAI/model-spec/specs-go/v1"
3535 sha256 "github.com/minio/sha256-simd"
36+ godigest "github.com/opencontainers/go-digest"
3637 spec "github.com/opencontainers/image-spec/specs-go"
3738 ocispec "github.com/opencontainers/image-spec/specs-go/v1"
3839)
@@ -58,7 +59,7 @@ type Builder interface {
5859 BuildLayer (ctx context.Context , mediaType , workDir , path string , hooks hooks.Hooks ) (ocispec.Descriptor , error )
5960
6061 // BuildConfig builds the config blob of the artifact.
61- BuildConfig (ctx context.Context , hooks hooks.Hooks ) (ocispec.Descriptor , error )
62+ BuildConfig (ctx context.Context , layers []ocispec. Descriptor , hooks hooks.Hooks ) (ocispec.Descriptor , error )
6263
6364 // BuildManifest builds the manifest blob of the artifact.
6465 BuildManifest (ctx context.Context , layers []ocispec.Descriptor , config ocispec.Descriptor , annotations map [string ]string , hooks hooks.Hooks ) (ocispec.Descriptor , error )
@@ -148,8 +149,8 @@ func (ab *abstractBuilder) BuildLayer(ctx context.Context, mediaType, workDir, p
148149 return ab .strategy .OutputLayer (ctx , mediaType , workDir , relPath , info .Size ()+ tarHeaderSize , reader , hooks )
149150}
150151
151- func (ab * abstractBuilder ) BuildConfig (ctx context.Context , hooks hooks.Hooks ) (ocispec.Descriptor , error ) {
152- config , err := buildModelConfig (ab .modelfile )
152+ func (ab * abstractBuilder ) BuildConfig (ctx context.Context , layers []ocispec. Descriptor , hooks hooks.Hooks ) (ocispec.Descriptor , error ) {
153+ config , err := buildModelConfig (ab .modelfile , layers )
153154 if err != nil {
154155 return ocispec.Descriptor {}, fmt .Errorf ("failed to build model config: %w" , err )
155156 }
@@ -189,7 +190,7 @@ func (ab *abstractBuilder) BuildManifest(ctx context.Context, layers []ocispec.D
189190}
190191
191192// buildModelConfig builds the model config.
192- func buildModelConfig (modelfile modelfile.Modelfile ) (* modelspec.Model , error ) {
193+ func buildModelConfig (modelfile modelfile.Modelfile , layers []ocispec. Descriptor ) (* modelspec.Model , error ) {
193194 config := modelspec.ModelConfig {
194195 Architecture : modelfile .GetArch (),
195196 Format : modelfile .GetFormat (),
@@ -205,8 +206,14 @@ func buildModelConfig(modelfile modelfile.Modelfile) (*modelspec.Model, error) {
205206 Name : modelfile .GetName (),
206207 }
207208
209+ diffIDs := make ([]godigest.Digest , 0 , len (layers ))
210+ for _ , layer := range layers {
211+ diffIDs = append (diffIDs , layer .Digest )
212+ }
213+
208214 fs := modelspec.ModelFS {
209- Type : "layers" ,
215+ Type : "layers" ,
216+ DiffIDs : diffIDs ,
210217 }
211218
212219 return & modelspec.Model {
0 commit comments