builder

package
v1.0.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2026 License: Apache-2.0, Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

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

func FromPath(path string) (*Builder, error)

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

func FromPaths(paths []string) (*Builder, error)

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

func (b *Builder) Build(ctx context.Context, target Target, pw io.Writer) error

Build finalizes the artifact and writes it to the given target, reporting progress to the given writer

func (*Builder) HasOnlyConfigChanges

func (b *Builder) HasOnlyConfigChanges() bool

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

func (b *Builder) WithChatTemplateFile(path string) (*Builder, error)

WithChatTemplateFile adds a Jinja chat template file to the artifact which takes precedence over template from GGUF.

func (*Builder) WithConfigArchive

func (b *Builder) WithConfigArchive(path string) (*Builder, error)

WithConfigArchive adds a config archive (tar) file to the artifact

func (*Builder) WithContextSize

func (b *Builder) WithContextSize(size int32) *Builder

func (*Builder) WithDirTar

func (b *Builder) WithDirTar(path string) (*Builder, error)

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

func (b *Builder) WithFileLayer(absPath, relPath string) (*Builder, error)

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

func (b *Builder) WithLicense(path string) (*Builder, error)

WithLicense adds a license file to the artifact

func (*Builder) WithMultimodalProjector

func (b *Builder) WithMultimodalProjector(path string) (*Builder, error)

WithMultimodalProjector adds a Multimodal projector 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.

type Target

type Target interface {
	Write(context.Context, types.ModelArtifact, io.Writer) error
}

Target represents a build target

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL