store

package
v0.40.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrConcurrentUpdate is returned when there is a concurrent update.
	ErrConcurrentUpdate = fmt.Errorf("store: concurrent update")
)

Functions

This section is empty.

Types

type BaseModel

type BaseModel struct {
	gorm.Model

	ModelID string `gorm:"uniqueIndex"`
	Path    string

	// GGUFModelPath is the path to the GGUF model.
	GGUFModelPath string
}

BaseModel represents a base model.

type Model

type Model struct {
	gorm.Model

	// ModelID is the model ID. It is globally unique.
	ModelID string `gorm:"uniqueIndex"`

	TenantID string `gorm:"index"`

	Path        string
	IsPublished bool
}

Model represents a model.

type ModelKey

type ModelKey struct {
	ModelID  string
	TenantID string
}

ModelKey represents a model key.

type ModelSpec

type ModelSpec struct {
	Key         ModelKey
	Path        string
	IsPublished bool
}

ModelSpec represents a model spec that is passed to CreateModel.

type S

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

S represents the data store.

func New

func New(db *gorm.DB) *S

New creates a new store instance.

func NewTest

func NewTest(t *testing.T) (*S, func())

NewTest returns a new test store.

func (*S) AutoMigrate

func (s *S) AutoMigrate() error

AutoMigrate sets up the auto-migration task of the database.

func (*S) CreateBaseModel

func (s *S) CreateBaseModel(modelID, path, ggufModelPath string) (*BaseModel, error)

CreateBaseModel creates a model.

func (*S) CreateModel

func (s *S) CreateModel(spec ModelSpec) (*Model, error)

CreateModel creates a model.

func (*S) DeleteModel

func (s *S) DeleteModel(k ModelKey) error

DeleteModel deletes a model by model ID and tenant ID.

func (*S) GetBaseModel

func (s *S) GetBaseModel(modelID string) (*BaseModel, error)

GetBaseModel returns a base model by model ID.

func (*S) GetModelByModelID added in v0.36.0

func (s *S) GetModelByModelID(modelID string) (*Model, error)

GetModelByModelID returns a model by model ID.

func (*S) GetPublishedModel added in v0.36.0

func (s *S) GetPublishedModel(k ModelKey) (*Model, error)

GetPublishedModel returns a published model by model ID and tenant ID.

func (*S) ListAllPublishedModels added in v0.36.0

func (s *S) ListAllPublishedModels() ([]*Model, error)

ListAllPublishedModels finds all published models.

func (*S) ListBaseModels

func (s *S) ListBaseModels() ([]*BaseModel, error)

ListBaseModels returns all base models.

func (*S) ListModelsByTenantID

func (s *S) ListModelsByTenantID(tenantID string, onlyPublished bool) ([]*Model, error)

ListModelsByTenantID finds models.

func (*S) UpdateModel

func (s *S) UpdateModel(k ModelKey, isPublished bool) error

UpdateModel updates the model.

Jump to

Keyboard shortcuts

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