Documentation
¶
Index ¶
- type Builder
- func (b *Builder) Build(ctx context.Context, target Target, pw io.Writer) error
- func (b *Builder) HasOnlyConfigChanges() bool
- func (b *Builder) Model() types.ModelArtifact
- func (b *Builder) WithChatTemplateFile(path string) (*Builder, error)
- func (b *Builder) WithConfigArchive(path string) (*Builder, error)
- func (b *Builder) WithContextSize(size int32) *Builder
- func (b *Builder) WithDirTar(path string) (*Builder, error)
- func (b *Builder) WithFileLayer(absPath, relPath string) (*Builder, error)
- func (b *Builder) WithLicense(path string) (*Builder, error)
- func (b *Builder) WithMultimodalProjector(path string) (*Builder, error)
- type DirectoryOption
- type DirectoryOptions
- type Target
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder builds a model artifact
func FromDirectory ¶ added in v1.0.14
func FromDirectory(dirPath string, opts ...DirectoryOption) (*Builder, error)
FromDirectory creates a Builder from a directory containing model files. It recursively scans the directory and adds each non-hidden file as a separate layer. Each layer's filepath annotation preserves the relative path from the directory root.
The directory structure is fully preserved, enabling support for nested HuggingFace models like Qwen3-TTS that have subdirectories (text_encoder/, vae/, etc.).
Example directory structure:
model_dir/
config.json -> layer with annotation "config.json"
model.safetensors -> layer with annotation "model.safetensors"
text_encoder/
config.json -> layer with annotation "text_encoder/config.json"
model.safetensors -> layer with annotation "text_encoder/model.safetensors"
Example with exclusions:
builder.FromDirectory(dirPath, builder.WithExclusions(".git", "__pycache__", "*.log"))
func FromModel ¶
func FromModel(mdl types.ModelArtifact) (*Builder, error)
FromModel returns a *Builder that builds model artifacts from an existing model artifact
func FromPath ¶ added in v1.0.11
FromPath returns a *Builder that builds model artifacts from a file path. It auto-detects the model format (GGUF or Safetensors) and discovers any shards. This is the preferred entry point for creating models from local files.
func FromPaths ¶ added in v1.0.11
FromPaths returns a *Builder that builds model artifacts from multiple file paths. All paths must be of the same format. Use this when you already have the list of files.
func (*Builder) Build ¶
Build finalizes the artifact and writes it to the given target, reporting progress to the given writer
func (*Builder) HasOnlyConfigChanges ¶
HasOnlyConfigChanges returns true if the builder was created from an existing model and only configuration changes were made (no layers added or removed). This is useful for determining if lightweight repackaging optimizations can be used.
func (*Builder) Model ¶
func (b *Builder) Model() types.ModelArtifact
Model returns the underlying model artifact
func (*Builder) WithChatTemplateFile ¶
WithChatTemplateFile adds a Jinja chat template file to the artifact which takes precedence over template from GGUF.
func (*Builder) WithConfigArchive ¶
WithConfigArchive adds a config archive (tar) file to the artifact
func (*Builder) WithContextSize ¶
func (*Builder) WithDirTar ¶
WithDirTar adds a directory tar archive to the artifact. Multiple directory tar archives can be added by calling this method multiple times.
func (*Builder) WithFileLayer ¶ added in v1.0.14
WithFileLayer adds an individual file layer with a relative path annotation. This is useful for adding files that should be extracted to a specific path.
func (*Builder) WithLicense ¶
WithLicense adds a license file to the artifact
type DirectoryOption ¶ added in v1.0.14
type DirectoryOption func(*DirectoryOptions)
DirectoryOption is a functional option for configuring FromDirectory.
func WithExclusions ¶ added in v1.0.14
func WithExclusions(patterns ...string) DirectoryOption
WithExclusions specifies patterns to exclude from packaging. Patterns can be directory names, file names, glob patterns, or specific paths.
Examples:
WithExclusions(".git", "__pycache__") // Exclude directories
WithExclusions("README.md", "CHANGELOG.md") // Exclude specific files
WithExclusions("*.log", "*.tmp") // Exclude by pattern
WithExclusions("logs/", "cache/") // Exclude directories (trailing slash)
type DirectoryOptions ¶ added in v1.0.14
type DirectoryOptions struct {
// Exclusions is a list of patterns to exclude from packaging.
// Patterns can be:
// - Directory names (e.g., ".git", "__pycache__") - excludes the entire directory
// - File names (e.g., "README.md") - excludes files with this exact name
// - Glob patterns (e.g., "*.log", "*.tmp") - excludes files matching the pattern
// - Paths with slashes (e.g., "logs/debug.log") - excludes specific paths
Exclusions []string
}
DirectoryOptions configures the behavior of FromDirectory.