Documentation
¶
Index ¶
- func ChatTemplatePath(i WithLayers) (string, error)
- func Config(i WithRawConfigFile) (types.ModelConfig, error)
- func ConfigArchivePath(i WithLayers) (string, error)
- func ConfigFile(i WithRawConfigFile) (*types.ConfigFile, error)
- func DDUFPaths(i WithLayers) ([]string, error)
- func Descriptor(i WithRawConfigFile) (types.Descriptor, error)
- func GGUFPaths(i WithLayers) ([]string, error)
- func ID(i WithRawManifest) (string, error)
- func MMPROJPath(i WithLayers) (string, error)
- func ManifestForLayers(i WithLayers) (*oci.Manifest, error)
- func SafetensorsPaths(i WithLayers) ([]string, error)
- type BaseModel
- func (m *BaseModel) Config() (types.ModelConfig, error)
- func (m *BaseModel) ConfigFile() (*oci.ConfigFile, error)
- func (m *BaseModel) ConfigName() (oci.Hash, error)
- func (m *BaseModel) Descriptor() (types.Descriptor, error)
- func (m *BaseModel) Digest() (oci.Hash, error)
- func (m *BaseModel) GetManifestOptions() ManifestOptions
- func (m *BaseModel) ID() (string, error)
- func (m *BaseModel) LayerByDiffID(hash oci.Hash) (oci.Layer, error)
- func (m *BaseModel) LayerByDigest(hash oci.Hash) (oci.Layer, error)
- func (m *BaseModel) Layers() ([]oci.Layer, error)
- func (m *BaseModel) Manifest() (*oci.Manifest, error)
- func (m *BaseModel) MediaType() (oci.MediaType, error)
- func (m *BaseModel) RawConfigFile() ([]byte, error)
- func (m *BaseModel) RawManifest() ([]byte, error)
- func (m *BaseModel) Size() (int64, error)
- type CNCFModel
- func (m *CNCFModel) Config() (types.ModelConfig, error)
- func (m *CNCFModel) ConfigFile() (*oci.ConfigFile, error)
- func (m *CNCFModel) ConfigName() (oci.Hash, error)
- func (m *CNCFModel) Descriptor() (types.Descriptor, error)
- func (m *CNCFModel) Digest() (oci.Hash, error)
- func (m *CNCFModel) GetManifestOptions() ManifestOptions
- func (m *CNCFModel) ID() (string, error)
- func (m *CNCFModel) LayerByDiffID(hash oci.Hash) (oci.Layer, error)
- func (m *CNCFModel) LayerByDigest(hash oci.Hash) (oci.Layer, error)
- func (m *CNCFModel) Layers() ([]oci.Layer, error)
- func (m *CNCFModel) Manifest() (*oci.Manifest, error)
- func (m *CNCFModel) MediaType() (oci.MediaType, error)
- func (m *CNCFModel) RawConfigFile() ([]byte, error)
- func (m *CNCFModel) RawManifest() ([]byte, error)
- func (m *CNCFModel) Size() (int64, error)
- type Layer
- func (l Layer) Compressed() (io.ReadCloser, error)
- func (l Layer) DiffID() (oci.Hash, error)
- func (l Layer) Digest() (oci.Hash, error)
- func (l Layer) GetDescriptor() oci.Descriptor
- func (l Layer) GetPath() string
- func (l Layer) MediaType() (oci.MediaType, error)
- func (l Layer) Size() (int64, error)
- func (l Layer) Uncompressed() (io.ReadCloser, error)
- type ManifestOptions
- type WithLayers
- type WithManifestOptions
- type WithRawConfigFile
- type WithRawManifest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChatTemplatePath ¶
func ChatTemplatePath(i WithLayers) (string, error)
func Config ¶
func Config(i WithRawConfigFile) (types.ModelConfig, error)
Config returns the model configuration. Returns *types.Config for Docker format or *modelpack.Model for ModelPack format, without any conversion.
func ConfigArchivePath ¶
func ConfigArchivePath(i WithLayers) (string, error)
func ConfigFile ¶
func ConfigFile(i WithRawConfigFile) (*types.ConfigFile, error)
ConfigFile returns the full Docker format config file (only for Docker format models).
func DDUFPaths ¶ added in v1.0.12
func DDUFPaths(i WithLayers) ([]string, error)
func Descriptor ¶
func Descriptor(i WithRawConfigFile) (types.Descriptor, error)
Descriptor returns the types.Descriptor for the model.
func GGUFPaths ¶
func GGUFPaths(i WithLayers) ([]string, error)
func ID ¶
func ID(i WithRawManifest) (string, error)
func MMPROJPath ¶
func MMPROJPath(i WithLayers) (string, error)
func ManifestForLayers ¶
func ManifestForLayers(i WithLayers) (*oci.Manifest, error)
ManifestForLayers assembles an OCI manifest for the given model. The config media type and optional artifact type are read from the model via the WithManifestOptions interface.
func SafetensorsPaths ¶
func SafetensorsPaths(i WithLayers) ([]string, error)
Types ¶
type BaseModel ¶ added in v1.0.3
type BaseModel struct {
ModelConfigFile types.ConfigFile
LayerList []oci.Layer
// ConfigMediaType specifies the media type for the config descriptor.
// If empty, defaults to MediaTypeModelConfigV01 for backward compatibility.
// Set to MediaTypeModelConfigV02 for layer-per-file packaging (FromDirectory).
ConfigMediaType oci.MediaType
}
BaseModel provides a common implementation for model types. It can be embedded by specific model format implementations (GGUF, Safetensors, etc.)
func (*BaseModel) ConfigFile ¶ added in v1.0.3
func (m *BaseModel) ConfigFile() (*oci.ConfigFile, error)
func (*BaseModel) Descriptor ¶ added in v1.0.3
func (m *BaseModel) Descriptor() (types.Descriptor, error)
func (*BaseModel) GetManifestOptions ¶ added in v1.1.36
func (m *BaseModel) GetManifestOptions() ManifestOptions
GetManifestOptions implements WithManifestOptions, providing the config media type for Docker-format models. If ConfigMediaType is not set, ManifestForLayers will default to V0.1.
func (*BaseModel) LayerByDiffID ¶ added in v1.0.3
func (*BaseModel) LayerByDigest ¶ added in v1.0.3
func (*BaseModel) RawConfigFile ¶ added in v1.0.3
func (*BaseModel) RawManifest ¶ added in v1.0.3
type CNCFModel ¶ added in v1.1.36
type CNCFModel struct {
// ModelPackConfig holds the CNCF ModelPack config to be serialized.
ModelPackConfig modelpack.Model
// LayerList is the ordered list of OCI layers.
LayerList []oci.Layer
}
CNCFModel is a model artifact whose config is serialized as a CNCF ModelPack config (application/vnd.cncf.model.config.v1+json) and whose manifest carries the required artifactType field.
func (*CNCFModel) ConfigFile ¶ added in v1.1.36
func (m *CNCFModel) ConfigFile() (*oci.ConfigFile, error)
func (*CNCFModel) Descriptor ¶ added in v1.1.36
func (m *CNCFModel) Descriptor() (types.Descriptor, error)
func (*CNCFModel) GetManifestOptions ¶ added in v1.1.36
func (m *CNCFModel) GetManifestOptions() ManifestOptions
GetManifestOptions implements WithManifestOptions, providing the CNCF config media type and required artifact type for the manifest.
func (*CNCFModel) LayerByDiffID ¶ added in v1.1.36
func (*CNCFModel) LayerByDigest ¶ added in v1.1.36
func (*CNCFModel) RawConfigFile ¶ added in v1.1.36
func (*CNCFModel) RawManifest ¶ added in v1.1.36
type Layer ¶
type Layer struct {
Path string
oci.Descriptor
}
func NewLayer ¶
NewLayer creates a new layer from a file path. The AnnotationFilePath annotation is set to the basename of the file.
func NewLayerWithRelativePath ¶ added in v1.0.14
NewLayerWithRelativePath creates a new layer with a custom relative path annotation. The relativePath parameter allows preserving nested directory structure (e.g., "text_encoder/model.safetensors"). This relative path is stored in the AnnotationFilePath annotation and used during unpacking.
func (Layer) Compressed ¶
func (l Layer) Compressed() (io.ReadCloser, error)
func (Layer) GetDescriptor ¶ added in v1.0.14
func (l Layer) GetDescriptor() oci.Descriptor
GetDescriptor returns the full descriptor including annotations. This allows accessing the AnnotationFilePath during unpacking.
func (Layer) GetPath ¶ added in v1.0.14
GetPath returns the local file path of the layer. This is used during unpacking to enable hard linking instead of copying.
func (Layer) Uncompressed ¶
func (l Layer) Uncompressed() (io.ReadCloser, error)
type ManifestOptions ¶ added in v1.1.36
type ManifestOptions struct {
// ConfigMediaType is the media type of the config blob.
ConfigMediaType oci.MediaType
// ArtifactType is the OCI artifact type of the manifest (optional).
// The CNCF ModelPack spec requires
// "application/vnd.cncf.model.manifest.v1+json".
ArtifactType string
}
ManifestOptions holds the manifest-level metadata for an artifact.
type WithLayers ¶
type WithLayers interface {
WithRawConfigFile
Layers() ([]oci.Layer, error)
}
type WithManifestOptions ¶ added in v1.1.36
type WithManifestOptions interface {
GetManifestOptions() ManifestOptions
}
WithManifestOptions provides manifest assembly options.
type WithRawConfigFile ¶
type WithRawManifest ¶
type WithRawManifest interface {
// RawManifest returns the serialized bytes of this model's manifest file.
RawManifest() ([]byte, error)
}
WithRawManifest defines the subset of types.Model used by these helper methods