llamacpp

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: Apache-2.0 Imports: 25 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package llamacpp adapts a supervised llama-server subprocess to the runtime.Runtime interface (SPEC §A1.3: subprocess, never cgo).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	Fetcher *Fetcher
	Accel   string // preferred accelerator backend from hardware detection
	// VRAMMB is the detected GPU memory (system RAM on Apple Silicon);
	// with budget.max_vram_percent it bounds GPU offload. 0 = unknown.
	VRAMMB uint64
	Log    *slog.Logger
	// ContextLength override (0 = model/catalog default).
	ContextLength int
	// MaxContext caps the window passed as --ctx-size (0 = no cap); see
	// config.Runtime.MaxContext.
	MaxContext int
}

Adapter implements runtime.Runtime by supervising llama-server and translating CompletionRequests to its OpenAI-compatible HTTP API.

func (*Adapter) Load

func (a *Adapter) Load(ctx context.Context, m rt.ModelSpec, res rt.ResourceBudget) (rt.Instance, error)

Load fetches/verifies the pinned llama-server build, launches it on an ephemeral loopback port with the model, health-gates it and returns the serving Instance.

type Artifact

type Artifact struct {
	OS     string `json:"os"`    // darwin|linux|windows
	Arch   string `json:"arch"`  // arm64|amd64
	Accel  string `json:"accel"` // metal|cuda12|rocm|vulkan|cpu-avx2
	URL    string `json:"url"`
	SHA256 string `json:"sha256"` // of the tarball
	Size   int64  `json:"size_bytes"`
}

type ArtifactManifest

type ArtifactManifest struct {
	RuntimeBuildID string     `json:"runtime_build_id"`
	Artifacts      []Artifact `json:"artifacts"`
}

ArtifactManifest mirrors teraflock/runtimes manifests/schema.json: one manifest per runtime_build_id, published alongside the tarballs. The build id participates in the fingerprint trust tuple (model_sha, quant, runtime_build_id) — SPEC §2.2. Fields the daemon does not act on (upstream_tag, created_at, …) are ignored rather than modelled, so a manifest format addition never requires a daemon release.

type Fetcher

type Fetcher struct {
	// ManifestURL points at the ArtifactManifest JSON. Required unless
	// BinaryPath overrides fetching entirely.
	ManifestURL string
	// BinaryPath, when set, skips download and uses an existing binary
	// (config runtime.llama_server_path).
	BinaryPath string
	CacheDir   string // e.g. <data_dir>/runtimes
	HTTPClient *http.Client
}

Fetcher downloads, SHA-verifies and unpacks the pinned llama-server build.

func (*Fetcher) Ensure

func (f *Fetcher) Ensure(ctx context.Context, accel string) (path, buildID string, err error)

Ensure returns the path to a verified llama-server binary and its build id.

func (*Fetcher) Preflight added in v0.1.1

func (f *Fetcher) Preflight(ctx context.Context, accel string) error

Preflight checks that a runtime binary is *resolvable* for this (GOOS, GOARCH, accel) without actually downloading the tarball. Used by `tera up` to refuse installing a service unit that would crash-loop on first start when the pinned catalog has no build for this machine. Returns nil when either f.BinaryPath is present on disk or f.ManifestURL advertises a matching artifact (cpu fallback included, same rule as Ensure).

Jump to

Keyboard shortcuts

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