store

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

store implements a model store which allows downloading models from a remote server

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewStore

func NewStore(path, ext, modelUrl string) (*Store, error)

Create a new model store

func (*Store) ById

func (s *Store) ById(id string) *schema.Model

Return a model by its Id

func (*Store) ByPath

func (s *Store) ByPath(path string) *schema.Model

Return a model by path

func (*Store) Delete

func (s *Store) Delete(id string) error

Delete a model by its Id

func (*Store) Download

func (s *Store) Download(ctx context.Context, path string, fn func(curBytes, totalBytes uint64)) (*schema.Model, error)

Download a model to the models directory. If the model already exists, it will be returned without downloading. The destination directory is relative to the models directory.

A function can be provided to track the progress of the download. If no Content-Length is provided by the server, the total bytes will be unknown and is set to zero.

func (*Store) List

func (s *Store) List() []*schema.Model

Return the models

func (*Store) MarshalJSON

func (s *Store) MarshalJSON() ([]byte, error)

func (*Store) Rescan

func (s *Store) Rescan() error

Rescan models directory

func (*Store) String

func (s *Store) String() string

Jump to

Keyboard shortcuts

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