Documentation
¶
Overview ¶
Package models manages ds4go's curated model catalog.
Index ¶
- Constants
- Variables
- func DefaultMTPPath() string
- func DefaultModelPath() string
- func GetLockHolder(path string) (int, error)
- func GetProcessName(pid int) string
- type Config
- type FileLock
- type Manager
- func (m *Manager) Delete(alias string) error
- func (m *Manager) Download(ctx context.Context, alias, token string) (Model, error)
- func (m *Manager) DownloadDryRun(ctx context.Context, alias, token string) (Model, error)
- func (m *Manager) List() ([]Model, Config, error)
- func (m *Manager) LoadConfig() (Config, error)
- func (m *Manager) SaveConfig(cfg Config) error
- func (m *Manager) Set(alias string) error
- type Model
Constants ¶
const ( // DefaultModelSymlink is the name of the active-model symlink in ModelsDir. DefaultModelSymlink = "ds4flash.gguf" // ConfigFileName is the ds4go configuration file name. ConfigFileName = "ds4go.json" // MTPAlias is the curated alias for the MTP companion model. MTPAlias = "mtp" // RecommendedModelAlias is the suggested default model for first-time users. RecommendedModelAlias = "q2-imatrix" )
Variables ¶
var ErrLocked = errors.New("lock already held by another process")
ErrLocked is returned by TryLock when another process already holds the lock.
Functions ¶
func DefaultMTPPath ¶ added in v0.2.2
func DefaultMTPPath() string
DefaultMTPPath returns the path to the installed MTP companion model, or empty string if it is not present.
func DefaultModelPath ¶
func DefaultModelPath() string
DefaultModelPath returns the configured default model path.
func GetLockHolder ¶ added in v0.4.0
GetLockHolder returns the PID of the process holding the lock on path. If the lock is not currently held, it returns 0, nil.
func GetProcessName ¶ added in v0.4.0
GetProcessName returns the executable name of the process with the given PID, or "unknown" if it cannot be determined.
Types ¶
type Config ¶
type Config struct {
DefaultModel string `json:"defaultModel"`
DS4Dir string `json:"ds4Dir"`
Models map[string]Model `json:"models"`
}
Config is stored at $DS4_DIR/ds4go.json.
type FileLock ¶ added in v0.4.0
type FileLock struct {
// contains filtered or unexported fields
}
FileLock is an advisory, OS-level exclusive lock. The kernel releases it automatically when the holding process exits, so an interrupted process never leaves a stale lock behind.
func AcquireEngineRunLock ¶ added in v0.4.0
AcquireEngineRunLock attempts to acquire the run lock file for a given model path. If the lock is already held by another process, it returns a descriptive error indicating the holding process PID and name.
func LockExclusive ¶ added in v0.4.0
LockExclusive acquires an exclusive lock on path, creating the file if needed. Unlike TryLock, it waits for the existing holder to release it.
type Manager ¶
type Manager struct {
DS4Dir string
ModelsDir string
ConfigPath string
HTTPClient *http.Client
Out io.Writer
ProgressOut io.Writer
}
Manager manages the local ds4 model directory and config.
func NewManager ¶
func NewManager() *Manager
NewManager returns a manager rooted at DS4_DIR or ~/.ds4.
func (*Manager) Delete ¶
Delete removes a curated model's downloaded file and any partial download. If the deleted model was the default, the default is cleared.
func (*Manager) Download ¶
Download downloads a curated model from Hugging Face with resume support.
func (*Manager) DownloadDryRun ¶
DownloadDryRun resolves alias and reports what Download would fetch — the source URL, destination path, remote size/SHA256, and current local state — without downloading anything.
func (*Manager) LoadConfig ¶
LoadConfig reads ds4go.json.
func (*Manager) SaveConfig ¶
SaveConfig writes ds4go.json.
type Model ¶
type Model struct {
Alias string `json:"alias"`
GGUFPath string `json:"ggufPath"`
FileName string `json:"fileName"`
SizeGB float64 `json:"sizeGB"`
RecommendedRAM string `json:"recommendedRAM"`
SHA256 string `json:"sha256,omitempty"`
Imatrix bool `json:"imatrix"`
Legacy bool `json:"legacy"`
Optional bool `json:"optional"`
Notes string `json:"notes,omitempty"`
Installed bool `json:"installed"`
Partial bool `json:"partial"`
PartialBytes int64 `json:"partialBytes,omitempty"`
Default bool `json:"default"`
}
Model describes a curated ds4 GGUF model.