runner

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateBackup

func CreateBackup(src string, backupDst string) error

CreateBackup backs up the src folder to backupDst atomically.

func DownloadAndInstallOnnxRuntime

func DownloadAndInstallOnnxRuntime(url string, destDir string, version string, downloadsDir string, progressChan chan float64) error

DownloadAndInstallOnnxRuntime downloads the ONNX release asset, extracts the library files, and writes a version.txt.

func DownloadRelease

func DownloadRelease(url string, destPath string, progressChan chan float64) error

DownloadRelease downloads an asset URL and writes progress fraction (0.0 to 1.0) to progressChan.

func ExtractArchive

func ExtractArchive(archivePath string, destDir string) error

ExtractArchive extracts zip/tar.gz into destDir and flattens single directories.

func ExtractOnnxLibrary

func ExtractOnnxLibrary(archivePath string, destDir string) error

ExtractOnnxLibrary extracts only the ONNX Runtime library from zip/tar.gz files.

func GetMemoryUsage

func GetMemoryUsage(pid int) (float64, error)

GetMemoryUsage queries physical memory usage (RSS) of a process in MB.

func MatchAsset

func MatchAsset(release *GithubRelease, specs *hardware.HardwareSpecs) (mainAsset *ReleaseAsset, cudartAsset *ReleaseAsset, err error)

MatchAsset finds the most suitable assets (main binaries and optional cudart DLLs) for the user's OS, CPU/GPU architecture.

func QueryLocalOnnxVersion

func QueryLocalOnnxVersion(onnxDir string) (string, error)

QueryLocalOnnxVersion checks the presence of ONNX library files and reads the version.txt if available.

func QueryLocalVersion

func QueryLocalVersion(llamaCppDir string) (version string, commit string, buildInfo string, err error)

QueryLocalVersion runs llama-server (or llama-cli) --version and parses output.

func QueryServerRequests

func QueryServerRequests(port int) (int, error)

QueryServerRequests queries total completion requests processed via the /metrics endpoint.

func RollbackBackup

func RollbackBackup(backupSrc string, dst string) error

RollbackBackup restores the backup directory.

Types

type GithubRelease

type GithubRelease struct {
	TagName string         `json:"tag_name"`
	Name    string         `json:"name"`
	Body    string         `json:"body"`
	Assets  []ReleaseAsset `json:"assets"`
}

func CheckAppRelease

func CheckAppRelease() (*GithubRelease, error)

CheckAppRelease queries GitHub API for the latest runora release or tag.

func CheckLatestOnnxRelease

func CheckLatestOnnxRelease() (*GithubRelease, error)

CheckLatestOnnxRelease queries GitHub API for the latest ONNX Runtime release.

func CheckLatestRelease

func CheckLatestRelease() (*GithubRelease, error)

CheckLatestRelease queries GitHub API for the latest llama.cpp release. Starting with v0.2.0, llama.cpp publishes stable semantic releases (vX.Y.Z) which reference the corresponding binary build tag inside nightly-tag.txt.

type GithubTag

type GithubTag struct {
	Name string `json:"name"`
}

type InstanceInfo

type InstanceInfo struct {
	Port      int
	ModelPath string
	PID       int
	Uptime    time.Duration
	LogFile   string
}

type LlamaCppRuntime

type LlamaCppRuntime struct {
	// contains filtered or unexported fields
}

func NewLlamaCppRuntime

func NewLlamaCppRuntime(logDir string) *LlamaCppRuntime

func (*LlamaCppRuntime) Capabilities

func (sr *LlamaCppRuntime) Capabilities() []TaskType

func (*LlamaCppRuntime) GetAllInstances

func (sr *LlamaCppRuntime) GetAllInstances() []InstanceInfo

GetAllInstances returns status information for all active servers.

func (*LlamaCppRuntime) GetStatus

func (sr *LlamaCppRuntime) GetStatus() (ServerStatus, string, int)

GetStatus returns the status, running model path, and port of the primary running server (50505 or first found).

func (*LlamaCppRuntime) Start

func (sr *LlamaCppRuntime) Start(modelPath string, opts StartOptions) error

Start launches the llama-server on the specified port.

func (*LlamaCppRuntime) Stop

func (sr *LlamaCppRuntime) Stop() error

Stop terminates ALL running servers.

func (*LlamaCppRuntime) StopInstance

func (sr *LlamaCppRuntime) StopInstance(port int) error

StopInstance terminates the server running on the specified port.

type ModelRuntime

type ModelRuntime interface {
	// Start launches the model server on the specified port.
	Start(modelPath string, opts StartOptions) error
	// Stop terminates all active server instances running under this runtime.
	Stop() error
	// StopInstance terminates the server running on a specific port.
	StopInstance(port int) error
	// GetStatus queries the state of the primary instance (e.g. on port 50505).
	GetStatus() (ServerStatus, string, int)
	// GetAllInstances returns all instances currently run by this backend.
	GetAllInstances() []InstanceInfo
	// Capabilities returns which task types this runtime is capable of running.
	Capabilities() []TaskType
}

type MultiRuntimeManager

type MultiRuntimeManager struct {
	// contains filtered or unexported fields
}

func NewMultiRuntimeManager

func NewMultiRuntimeManager(logDir string) *MultiRuntimeManager

func (*MultiRuntimeManager) Capabilities

func (m *MultiRuntimeManager) Capabilities() []TaskType

func (*MultiRuntimeManager) GetAllInstances

func (m *MultiRuntimeManager) GetAllInstances() []InstanceInfo

func (*MultiRuntimeManager) GetStatus

func (m *MultiRuntimeManager) GetStatus() (ServerStatus, string, int)

func (*MultiRuntimeManager) Start

func (m *MultiRuntimeManager) Start(modelPath string, opts StartOptions) error

func (*MultiRuntimeManager) Stop

func (m *MultiRuntimeManager) Stop() error

func (*MultiRuntimeManager) StopInstance

func (m *MultiRuntimeManager) StopInstance(port int) error

type OnnxInstance

type OnnxInstance struct {
	Port       int
	ModelPath  string
	PID        int
	LaunchTime time.Time
	LogFile    string
}

type OnnxRuntime

type OnnxRuntime struct {
	// contains filtered or unexported fields
}

func NewOnnxRuntime

func NewOnnxRuntime(logDir string) *OnnxRuntime

func (*OnnxRuntime) Capabilities

func (or *OnnxRuntime) Capabilities() []TaskType

func (*OnnxRuntime) GetAllInstances

func (or *OnnxRuntime) GetAllInstances() []InstanceInfo

func (*OnnxRuntime) GetStatus

func (or *OnnxRuntime) GetStatus() (ServerStatus, string, int)

func (*OnnxRuntime) Start

func (or *OnnxRuntime) Start(modelPath string, opts StartOptions) error

func (*OnnxRuntime) Stop

func (or *OnnxRuntime) Stop() error

func (*OnnxRuntime) StopInstance

func (or *OnnxRuntime) StopInstance(port int) error

type ReleaseAsset

type ReleaseAsset struct {
	Name               string `json:"name"`
	BrowserDownloadURL string `json:"browser_download_url"`
	Size               int64  `json:"size"`
}

func MatchOnnxAsset

func MatchOnnxAsset(release *GithubRelease, specs *hardware.HardwareSpecs) (*ReleaseAsset, error)

MatchOnnxAsset finds the most suitable ONNX Runtime release package.

type ServerInstance

type ServerInstance struct {
	Port       int
	ModelPath  string
	PID        int
	Cmd        *exec.Cmd
	LaunchTime time.Time
	LogFile    string
	// contains filtered or unexported fields
}

type ServerStatus

type ServerStatus int
const (
	StatusStopped ServerStatus = iota
	StatusRunning
	StatusFailed
)

type StartOptions

type StartOptions struct {
	LlamaCppDir string // Specific to llama.cpp binaries
	ContextSize uint32
	Threads     int
	GPULayers   int
	BatchSize   int
	Host        string
	Port        int
}

type TaskType

type TaskType string
const (
	TaskTextGeneration  TaskType = "TEXT_GENERATION"
	TaskEmbedding       TaskType = "EMBEDDING"
	TaskReranking       TaskType = "RERANKING"
	TaskSpeechToText    TaskType = "SPEECH_TO_TEXT"
	TaskTextToSpeech    TaskType = "TEXT_TO_SPEECH"
	TaskImageGeneration TaskType = "IMAGE_GENERATION"
	TaskVision          TaskType = "VISION"
	TaskMultimodal      TaskType = "MULTIMODAL"
)

Jump to

Keyboard shortcuts

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