repository

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package repository provides a model repository for storing and managing GGUF model files.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when a model is not found.
	ErrNotFound = errors.New("repository: model not found")
	// ErrAlreadyExists is returned when a model with the same ID already exists.
	ErrAlreadyExists = errors.New("repository: model already exists")
	// ErrPathTraversal is returned when a model ID attempts to escape the base directory.
	ErrPathTraversal = errors.New("repository: path traversal detected")
)

Functions

This section is empty.

Types

type FileSystemRepository

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

FileSystemRepository implements ModelRepository using local filesystem storage. Models are stored as {baseDir}/{modelID}/model.gguf with a metadata.json sidecar.

func NewFileSystemRepository

func NewFileSystemRepository(baseDir string) (*FileSystemRepository, error)

NewFileSystemRepository creates a new FileSystemRepository rooted at baseDir. The directory is created if it does not exist.

func (*FileSystemRepository) Delete

func (r *FileSystemRepository) Delete(id string) error

Delete removes a model and its metadata from disk.

func (*FileSystemRepository) Get

Get returns metadata for a specific model.

func (*FileSystemRepository) List

func (r *FileSystemRepository) List() ([]ModelMetadata, error)

List returns metadata for all stored models.

func (*FileSystemRepository) Upload

func (r *FileSystemRepository) Upload(meta ModelMetadata, data io.Reader) error

Upload stores a model file and writes its metadata sidecar.

type Handler

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

Handler provides HTTP handlers for the model repository.

func NewHandler

func NewHandler(repo ModelRepository) *Handler

NewHandler creates a new Handler backed by the given repository.

func (*Handler) RegisterRoutes

func (h *Handler) RegisterRoutes(mux *http.ServeMux)

RegisterRoutes registers the repository HTTP routes on the given mux.

type ModelMetadata

type ModelMetadata struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	Version   string    `json:"version"`
	Format    string    `json:"format"`
	Size      int64     `json:"size"`
	SHA256    string    `json:"sha256"`
	CreatedAt time.Time `json:"created_at"`
}

ModelMetadata describes a stored model.

type ModelRepository

type ModelRepository interface {
	// List returns metadata for all stored models.
	List() ([]ModelMetadata, error)
	// Get returns metadata for a specific model.
	Get(id string) (ModelMetadata, error)
	// Upload stores a model file and its metadata. The reader provides the model data.
	Upload(meta ModelMetadata, r io.Reader) error
	// Delete removes a model and its metadata.
	Delete(id string) error
}

ModelRepository defines the interface for managing model storage.

type ReadCloserFunc

type ReadCloserFunc struct {
	io.Reader
}

ReadCloserFunc wraps an io.Reader with a no-op Close for use as io.ReadCloser.

func (ReadCloserFunc) Close

func (ReadCloserFunc) Close() error

Close is a no-op.

Jump to

Keyboard shortcuts

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