Documentation
¶
Index ¶
- Variables
- func CreateModelActivationStatusInTransaction(tx *gorm.DB, status *ModelActivationStatus) error
- func CreateModelConfigInTransaction(tx *gorm.DB, c *ModelConfig) error
- func DeleteBaseModelInTransaction(tx *gorm.DB, k ModelKey) error
- func DeleteHFModelRepoInTransactionByModelID(tx *gorm.DB, k ModelKey) error
- func DeleteModelActivationStatusInTransaction(tx *gorm.DB, k ModelKey) error
- func DeleteModelConfigInTransaction(tx *gorm.DB, k ModelKey) error
- func DeleteModelInTransaction(tx *gorm.DB, modelID, tenantID string) error
- func UnmarshalModelFormats(b []byte) ([]v1.ModelFormat, error)
- func UpdateModelConfigInTransaction(tx *gorm.DB, k ModelKey, encodedConfig []byte) error
- type BaseModel
- func CreateBaseModelInTransaction(tx *gorm.DB, k ModelKey, path string, formats []v1.ModelFormat, ...) (*BaseModel, error)
- func CreateBaseModelWithLoadingRequestedInTransaction(tx *gorm.DB, k ModelKey, sourceRepository v1.SourceRepository) (*BaseModel, error)
- func ListBaseModelsByActivationStatusWithPaginationInTransaction(tx *gorm.DB, projectID string, tenantID string, status v1.ActivationStatus, ...) ([]*BaseModel, bool, error)
- type HFModelRepo
- type Model
- type ModelActivationStatus
- type ModelConfig
- type ModelKey
- type ModelSpec
- type S
- func (s *S) AutoMigrate() error
- func (s *S) CountBaseModels(projectID, tenantID string, includeLoadingModels bool) (int64, error)
- func (s *S) CountModelsByProjectID(projectID string, onlyPublished bool, includeLoadingModels bool) (int64, error)
- func (s *S) CreateBaseModel(k ModelKey, path string, formats []v1.ModelFormat, ggufModelPath string, ...) (*BaseModel, error)
- func (s *S) CreateBaseModelWithLoadingRequested(k ModelKey, sourceRepository v1.SourceRepository) (*BaseModel, error)
- func (s *S) CreateHFModelRepo(r *HFModelRepo) error
- func (s *S) CreateModel(spec ModelSpec) (*Model, error)
- func (s *S) CreateModelActivationStatus(status *ModelActivationStatus) error
- func (s *S) CreateModelConfig(c *ModelConfig) error
- func (s *S) CreateStorageConfig(tenantID, pathPrefix string) (*StorageConfig, error)
- func (s *S) DeleteBaseModel(k ModelKey) error
- func (s *S) DeleteModel(modelID, tenantID string) error
- func (s *S) DeleteModelActivationStatus(k ModelKey) error
- func (s *S) DeleteModelConfig(k ModelKey) error
- func (s *S) GetBaseModel(k ModelKey) (*BaseModel, error)
- func (s *S) GetHFModelRepo(name, projectID string, tenantID string) (*HFModelRepo, error)
- func (s *S) GetModelActivationStatus(k ModelKey) (*ModelActivationStatus, error)
- func (s *S) GetModelByModelIDAndTenantID(modelID, tenantID string) (*Model, error)
- func (s *S) GetModelConfig(k ModelKey) (*ModelConfig, error)
- func (s *S) GetPublishedModelByModelIDAndTenantID(modelID, tenantID string) (*Model, error)
- func (s *S) GetStorageConfig(tenantID string) (*StorageConfig, error)
- func (s *S) ListBaseModelsByModelIDAndTenantID(modelID, tenantID string) ([]*BaseModel, error)
- func (s *S) ListBaseModelsByTenantID(tenantID string) ([]*BaseModel, error)
- func (s *S) ListHFModelRepos(tenantID string) ([]*HFModelRepo, error)
- func (s *S) ListLoadingBaseModels(tenantID string) ([]*BaseModel, error)
- func (s *S) ListModelsByProjectID(projectID string, onlyPublished bool) ([]*Model, error)
- func (s *S) ListModelsByTenantID(tenantID string) ([]*Model, error)
- func (s *S) ListUnloadedBaseModels(tenantID string) ([]*BaseModel, error)
- func (s *S) ListUnloadedModels(tenantID string) ([]*Model, error)
- func (s *S) Transaction(f func(*gorm.DB) error) error
- func (s *S) UpdateBaseModelLoadingStatusMessage(k ModelKey, msg string) error
- func (s *S) UpdateBaseModelToFailedStatus(k ModelKey, failureReason string) error
- func (s *S) UpdateBaseModelToLoadingStatus(k ModelKey) error
- func (s *S) UpdateBaseModelToSucceededStatus(k ModelKey, path string, formats []v1.ModelFormat, ggufModelPath string) error
- func (s *S) UpdateModelActivationStatus(k ModelKey, status v1.ActivationStatus) error
- func (s *S) UpdateModelConfig(k ModelKey, encodedConfig []byte) error
- func (s *S) UpdateModelLoadingStatusMessage(modelID, tenantID, msg string) error
- func (s *S) UpdateModelPublishingStatus(modelID string, tenantID string, isPublished bool, ...) error
- func (s *S) UpdateModelToFailedStatus(modelID string, tenantID string, failureReason string) error
- func (s *S) UpdateModelToLoadingStatus(modelID string, tenantID string) error
- func (s *S) UpdateModelToSucceededStatus(modelID string, tenantID string) error
- type StorageConfig
Constants ¶
This section is empty.
Variables ¶
var ( // ErrConcurrentUpdate is returned when there is a concurrent update. ErrConcurrentUpdate = fmt.Errorf("store: concurrent update") )
Functions ¶
func CreateModelActivationStatusInTransaction ¶ added in v1.17.0
func CreateModelActivationStatusInTransaction(tx *gorm.DB, status *ModelActivationStatus) error
CreateModelActivationStatusInTransaction creates a new model activation status in a transaction.
func CreateModelConfigInTransaction ¶ added in v1.24.0
func CreateModelConfigInTransaction(tx *gorm.DB, c *ModelConfig) error
CreateModelConfigInTransaction creates a new model config in a transaction.
func DeleteBaseModelInTransaction ¶ added in v1.10.0
DeleteBaseModelInTransaction deletes a base model.
func DeleteHFModelRepoInTransactionByModelID ¶ added in v1.14.0
DeleteHFModelRepoInTransactionByModelID deletes a model repo.
func DeleteModelActivationStatusInTransaction ¶ added in v1.17.0
DeleteModelActivationStatusInTransaction deletes the model activation status.
func DeleteModelConfigInTransaction ¶ added in v1.24.0
DeleteModelConfigInTransaction deletes the model config.
func DeleteModelInTransaction ¶ added in v1.17.0
DeleteModelInTransaction deletes a model by model ID and tenant ID in a transaction.
func UnmarshalModelFormats ¶
func UnmarshalModelFormats(b []byte) ([]v1.ModelFormat, error)
UnmarshalModelFormats unmarshals model formats.
Types ¶
type BaseModel ¶
type BaseModel struct {
gorm.Model
TenantID string `gorm:"uniqueIndex:idx_base_model_model_id_tenant_id_project_id"`
ModelID string `gorm:"uniqueIndex:idx_base_model_model_id_tenant_id_project_id"`
// ProjectID is the ID of the project to which the model belongs. It is empty if
// the model is globally scoped and it is not associated with any project.
ProjectID string `gorm:"uniqueIndex:idx_base_model_model_id_tenant_id_project_id"`
Path string
Formats []byte
// GGUFModelPath is the path to the GGUF model.
GGUFModelPath string
SourceRepository v1.SourceRepository
LoadingStatus v1.ModelLoadingStatus
LoadingFailureReason string
LoadingStatusMessage string
}
BaseModel represents a base model.
func CreateBaseModelInTransaction ¶ added in v1.17.0
func CreateBaseModelInTransaction( tx *gorm.DB, k ModelKey, path string, formats []v1.ModelFormat, ggufModelPath string, sourceRepository v1.SourceRepository, ) (*BaseModel, error)
CreateBaseModelInTransaction creates a model in a transaction.
func CreateBaseModelWithLoadingRequestedInTransaction ¶ added in v1.17.0
func CreateBaseModelWithLoadingRequestedInTransaction( tx *gorm.DB, k ModelKey, sourceRepository v1.SourceRepository, ) (*BaseModel, error)
CreateBaseModelWithLoadingRequestedInTransaction creates a model with the requested loading status in a transaction.
func ListBaseModelsByActivationStatusWithPaginationInTransaction ¶ added in v1.20.0
func ListBaseModelsByActivationStatusWithPaginationInTransaction( tx *gorm.DB, projectID string, tenantID string, status v1.ActivationStatus, afterModelID string, limit int, includeLoadingModels bool, ) ([]*BaseModel, bool, error)
ListBaseModelsByActivationStatusWithPaginationInTransaction finds base models filtered by activation status with pagination in a transaction. Models are returned with an ascending order of model IDs.
type HFModelRepo ¶ added in v1.4.0
type HFModelRepo struct {
gorm.Model
Name string `gorm:"uniqueIndex:idx_hf_model_repo_name_tenant_id_project_id"`
ModelID string `gorm:"uniqueIndex:idx_hf_model_repo_model_id_tenant_id_project_id"`
TenantID string `gorm:"uniqueIndex:idx_hf_model_repo_name_tenant_id_project_id;uniqueIndex:idx_hf_model_repo_model_id_tenant_id_project_id"`
ProjectID string `gorm:"uniqueIndex:idx_hf_model_repo_name_tenant_id_project_id;uniqueIndex:idx_hf_model_repo_model_id_tenant_id_project_id"`
}
HFModelRepo represents a HuggingFace model repository where models are downloaded from. This is used to track a HuggingFace repo that has one-to-many mapping to base models.
The record is created when the download completes.
type Model ¶
type Model struct {
gorm.Model
TenantID string `gorm:"uniqueIndex:idx_model_model_id_tenant_id"`
ModelID string `gorm:"uniqueIndex:idx_model_model_id_tenant_id"`
OrganizationID string
ProjectID string `gorm:"index"`
Path string
IsPublished bool
BaseModelID string `gorm:"index"`
Adapter v1.AdapterType
Quantization v1.QuantizationType
LoadingStatus v1.ModelLoadingStatus
LoadingFailureReason string
LoadingStatusMessage string
SourceRepository v1.SourceRepository
ModelFileLocation string
}
Model represents a model.
func CreateModelInTransaction ¶ added in v1.17.0
CreateModelInTransaction creates a model in a transaction.
func ListModelsByActivationStatusWithPaginationInTransaction ¶ added in v1.20.0
func ListModelsByActivationStatusWithPaginationInTransaction( tx *gorm.DB, projectID string, onlyPublished bool, status v1.ActivationStatus, afterModelID string, limit int, includeLoadingModels bool, ) ([]*Model, bool, error)
ListModelsByActivationStatusWithPaginationInTransaction finds models filtered by activation status with pagination in a transaction. Models are returned with an ascending order of model IDs.
type ModelActivationStatus ¶ added in v1.17.0
type ModelActivationStatus struct {
gorm.Model
TenantID string `gorm:"uniqueIndex:idx_model_activation_status_model_id_tenant_id_project_id"`
ModelID string `gorm:"uniqueIndex:idx_model_activation_status_model_id_tenant_id_project_id"`
// ProjectID is set only for project-scoped base models. This is set to empty
// for global-scoped base models and fine-tuned models. (Fine-tuned models have emtpy values
// for backward compatibility.)
ProjectID string `gorm:"uniqueIndex:idx_model_activation_status_model_id_tenant_id_project_id"`
Status v1.ActivationStatus
}
ModelActivationStatus represents a model activation status.
func GetModelActivationStatusInTransaction ¶ added in v1.20.0
func GetModelActivationStatusInTransaction(tx *gorm.DB, k ModelKey) (*ModelActivationStatus, error)
GetModelActivationStatusInTransaction retrieves the model activation status in a transaction.
type ModelConfig ¶ added in v1.24.0
type ModelConfig struct {
gorm.Model
TenantID string `gorm:"uniqueIndex:idx_model_config_model_id_tenant_id_project_id"`
ModelID string `gorm:"uniqueIndex:idx_model_config_model_id_tenant_id_project_id"`
// ProjectID is set only for project-scoped base models. This is set to empty
// for global-scoped base models and fine-tuned models.
ProjectID string `gorm:"uniqueIndex:idx_model_config_model_id_tenant_id_project_id"`
// EncodedConfig is a proto-encoded message that contains v1.ModelConfig.
EncodedConfig []byte
}
ModelConfig represents a model configuration.
func GetModelConfigInTransaction ¶ added in v1.24.0
func GetModelConfigInTransaction(tx *gorm.DB, k ModelKey) (*ModelConfig, error)
GetModelConfigInTransaction retrieves the model config in a transaction.
type ModelSpec ¶
type ModelSpec struct {
ModelID string
TenantID string
OrganizationID string
ProjectID string
Path string
IsPublished bool
BaseModelID string
Adapter v1.AdapterType
Quantization v1.QuantizationType
LoadingStatus v1.ModelLoadingStatus
SourceRepository v1.SourceRepository
ModelFileLocation string
}
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 (*S) AutoMigrate ¶
AutoMigrate sets up the auto-migration task of the database.
func (*S) CountBaseModels ¶ added in v1.11.0
CountBaseModels counts the total number of base models.
func (*S) CountModelsByProjectID ¶ added in v1.11.0
func (s *S) CountModelsByProjectID( projectID string, onlyPublished bool, includeLoadingModels bool, ) (int64, error)
CountModelsByProjectID counts the total number of models by project ID.
func (*S) CreateBaseModel ¶
func (s *S) CreateBaseModel( k ModelKey, path string, formats []v1.ModelFormat, ggufModelPath string, sourceRepository v1.SourceRepository, ) (*BaseModel, error)
CreateBaseModel creates a model.
func (*S) CreateBaseModelWithLoadingRequested ¶ added in v1.10.0
func (s *S) CreateBaseModelWithLoadingRequested( k ModelKey, sourceRepository v1.SourceRepository, ) (*BaseModel, error)
CreateBaseModelWithLoadingRequested creates a model with the requested loading status.
func (*S) CreateHFModelRepo ¶ added in v1.4.0
func (s *S) CreateHFModelRepo(r *HFModelRepo) error
CreateHFModelRepo creates a model repo.
func (*S) CreateModel ¶
CreateModel creates a model.
func (*S) CreateModelActivationStatus ¶ added in v1.17.0
func (s *S) CreateModelActivationStatus(status *ModelActivationStatus) error
CreateModelActivationStatus creates a new model activation status.
func (*S) CreateModelConfig ¶ added in v1.24.0
func (s *S) CreateModelConfig(c *ModelConfig) error
CreateModelConfig creates a new model config.
func (*S) CreateStorageConfig ¶
func (s *S) CreateStorageConfig(tenantID, pathPrefix string) (*StorageConfig, error)
CreateStorageConfig creates a storage configuration.
func (*S) DeleteBaseModel ¶ added in v1.9.0
DeleteBaseModel deletes a base model by model ID and tenant ID.
func (*S) DeleteModel ¶
DeleteModel deletes a model by model ID and tenant ID.
func (*S) DeleteModelActivationStatus ¶ added in v1.17.0
DeleteModelActivationStatus deletes the model activation status.
func (*S) DeleteModelConfig ¶ added in v1.24.0
DeleteModelConfig deletes the model config.
func (*S) GetBaseModel ¶
GetBaseModel returns a base model by a model key.
func (*S) GetHFModelRepo ¶ added in v1.4.0
func (s *S) GetHFModelRepo(name, projectID string, tenantID string) (*HFModelRepo, error)
GetHFModelRepo returns a repo by the repo namen and tenant ID.
func (*S) GetModelActivationStatus ¶ added in v1.17.0
func (s *S) GetModelActivationStatus(k ModelKey) (*ModelActivationStatus, error)
GetModelActivationStatus retrieves the model activation status.
func (*S) GetModelByModelIDAndTenantID ¶ added in v1.14.0
GetModelByModelIDAndTenantID returns a model by model ID and tenant ID.
func (*S) GetModelConfig ¶ added in v1.24.0
func (s *S) GetModelConfig(k ModelKey) (*ModelConfig, error)
GetModelConfig retrieves the model config.
func (*S) GetPublishedModelByModelIDAndTenantID ¶
GetPublishedModelByModelIDAndTenantID returns a published model by model ID and tenant ID.
func (*S) GetStorageConfig ¶
func (s *S) GetStorageConfig(tenantID string) (*StorageConfig, error)
GetStorageConfig returns a storage configuration by tenant ID.
func (*S) ListBaseModelsByModelIDAndTenantID ¶ added in v1.22.0
ListBaseModelsByModelIDAndTenantID returns all base models that has a given ID for a tenant, including both global-scoped ones and project-scoped ones.
func (*S) ListBaseModelsByTenantID ¶ added in v1.22.0
ListBaseModelsByTenantID returns all base models for a tenant.
func (*S) ListHFModelRepos ¶ added in v1.4.0
func (s *S) ListHFModelRepos(tenantID string) ([]*HFModelRepo, error)
ListHFModelRepos returns all HuggingFace model repos for a tenant.
func (*S) ListLoadingBaseModels ¶ added in v1.22.0
ListLoadingBaseModels returns all base models with the loading status.
func (*S) ListModelsByProjectID ¶
ListModelsByProjectID returns all models by project ID.
func (*S) ListModelsByTenantID ¶ added in v1.18.0
ListModelsByTenantID returns all models by tenant ID.
func (*S) ListUnloadedBaseModels ¶ added in v1.10.0
ListUnloadedBaseModels returns all unloaded base models with the requested loading status.
func (*S) ListUnloadedModels ¶ added in v1.14.0
ListUnloadedModels returns all unloaded base models with the requested loading status.
func (*S) Transaction ¶ added in v1.10.0
Transaction runs a given function in a transaction.
func (*S) UpdateBaseModelLoadingStatusMessage ¶ added in v1.23.0
UpdateBaseModelLoadingStatusMessage updates the loading status message of a base model.
func (*S) UpdateBaseModelToFailedStatus ¶ added in v1.10.0
UpdateBaseModelToFailedStatus updates the loading status to FAILED and updates other relevant information.
func (*S) UpdateBaseModelToLoadingStatus ¶ added in v1.10.0
UpdateBaseModelToLoadingStatus updates the loading status to LOADING.
func (*S) UpdateBaseModelToSucceededStatus ¶ added in v1.10.0
func (s *S) UpdateBaseModelToSucceededStatus( k ModelKey, path string, formats []v1.ModelFormat, ggufModelPath string, ) error
UpdateBaseModelToSucceededStatus updates the loading status to SUCCEEDED and updates other relevant information.
func (*S) UpdateModelActivationStatus ¶ added in v1.17.0
func (s *S) UpdateModelActivationStatus(k ModelKey, status v1.ActivationStatus) error
UpdateModelActivationStatus updates the model activation status.
func (*S) UpdateModelConfig ¶ added in v1.24.0
UpdateModelConfig updates the model config.
func (*S) UpdateModelLoadingStatusMessage ¶ added in v1.23.0
UpdateModelLoadingStatusMessage updates the loading status message of a base model.
func (*S) UpdateModelPublishingStatus ¶ added in v1.14.0
func (s *S) UpdateModelPublishingStatus(modelID string, tenantID string, isPublished bool, loadingStatus v1.ModelLoadingStatus) error
UpdateModelPublishingStatus updates the publishing status of a model.
func (*S) UpdateModelToFailedStatus ¶ added in v1.14.0
UpdateModelToFailedStatus updates the loading status to FAILED and updates other relevant information.
func (*S) UpdateModelToLoadingStatus ¶ added in v1.14.0
UpdateModelToLoadingStatus updates the loading status to LOADING.