Documentation
¶
Index ¶
- func DetectPipelineTag(modelDir string) string
- func EnsureLocalModelFiles(modelDir string, m *LocalModel) (bool, error)
- func EnsureModelDir(baseDir, namespace, name string) error
- func FindMMProj(modelDir string) string
- func InferenceModelID(lm *LocalModel) string
- func IsASRArchitecture(architecture string) bool
- func IsASRModelFamily(name string) bool
- func IsEmbeddingArchitecture(architecture string) bool
- func IsPythonEmbeddingArchitecture(architecture string) bool
- func IsVisionArchitecture(architecture string) bool
- func ListModelsInNamespace(baseDir, namespace string) ([]string, error)
- func ListNamespaces(baseDir string) ([]string, error)
- func ManifestPath(baseDir, namespace, name string) string
- func ModelDir(baseDir, namespace, name string) string
- func PublicModelIDs(models []*LocalModel) map[string]string
- func RemoveModelDir(baseDir, namespace, name string) error
- func SaveManifest(baseDir string, m *LocalModel) error
- func SaveManifestInDir(modelDir string, m *LocalModel) error
- type Format
- type ImportOptions
- type ImportSourceKind
- type LocalModel
- type LocalModelFile
- type LocalModelOrigin
- type Manager
- func (m *Manager) Client() *csghub.Client
- func (m *Manager) Exists(modelID string) bool
- func (m *Manager) Get(modelID string) (*LocalModel, error)
- func (m *Manager) GetWithFileEntries(modelID string) (*LocalModel, error)
- func (m *Manager) Import(opts ImportOptions) (*LocalModel, error)
- func (m *Manager) ImportPreparedDirectory(opts ImportOptions) (*LocalModel, error)
- func (m *Manager) List() ([]*LocalModel, error)
- func (m *Manager) ModelPath(modelID string) (string, error)
- func (m *Manager) PublicModelID(modelID string) (string, error)
- func (m *Manager) Pull(ctx context.Context, modelID string, quants []string, ...) (*LocalModel, error)
- func (m *Manager) Remove(modelID string) error
- func (m *Manager) ResolveLocalModel(modelID string) (*LocalModel, error)
- func (m *Manager) ResolveLocalModelID(modelID string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetectPipelineTag ¶
DetectPipelineTag reads config.json in modelDir and returns a local pipeline tag for routing. Sentence-transformers repositories are treated as embedding models even when the hub metadata was not persisted in older manifests.
func EnsureLocalModelFiles ¶
func EnsureLocalModelFiles(modelDir string, m *LocalModel) (bool, error)
func EnsureModelDir ¶
EnsureModelDir creates the directory for a model if it doesn't exist.
func FindMMProj ¶
FindMMProj looks for a multimodal projector GGUF file (mmproj) in the model directory.
func InferenceModelID ¶
func InferenceModelID(lm *LocalModel) string
InferenceModelID returns the public model identifier used for local inference APIs.
func IsASRArchitecture ¶
IsASRArchitecture reports whether the HuggingFace architecture is an automatic speech recognition model.
func IsASRModelFamily ¶
IsASRModelFamily reports whether a model id/name belongs to a known ASR family served by the Python ASR runtime.
func IsEmbeddingArchitecture ¶
IsEmbeddingArchitecture reports whether the HuggingFace architecture is treated as a local embedding model by csghub-lite.
func IsPythonEmbeddingArchitecture ¶ added in v0.9.8
IsPythonEmbeddingArchitecture reports whether the HuggingFace architecture is supported by csghub-lite's Python embedding runtime.
func IsVisionArchitecture ¶
IsVisionArchitecture reports whether the HuggingFace architecture is a supported multimodal vision-language model.
func ListModelsInNamespace ¶
ListModelsInNamespace returns all model directories under a namespace.
func ListNamespaces ¶
ListNamespaces returns all namespace directories under the model base dir.
func ManifestPath ¶
ManifestPath returns the path to the manifest file for a model.
func PublicModelIDs ¶
func PublicModelIDs(models []*LocalModel) map[string]string
PublicModelIDs returns stable short model IDs keyed by each model's full namespace/name ID. When names collide, the first downloaded model keeps the bare name and later colliding models get a stable hash suffix.
func RemoveModelDir ¶
RemoveModelDir removes the directory for a model.
func SaveManifest ¶
func SaveManifest(baseDir string, m *LocalModel) error
SaveManifest writes a model manifest to disk.
func SaveManifestInDir ¶
func SaveManifestInDir(modelDir string, m *LocalModel) error
SaveManifestInDir writes a manifest to a prepared model directory before it is installed.
Types ¶
type Format ¶
type Format string
func DetectFormat ¶
DetectFormat guesses the model format from the file names.
type ImportOptions ¶
type ImportOptions struct {
ModelID string
Source string
Kind ImportSourceKind
Overwrite bool
}
type ImportSourceKind ¶
type ImportSourceKind string
const ( ImportSourceDirectory ImportSourceKind = "directory" ImportSourceArchive ImportSourceKind = "archive" )
type LocalModel ¶
type LocalModel struct {
Namespace string `json:"namespace"`
Name string `json:"name"`
Format Format `json:"format"`
Size int64 `json:"size"`
Files []string `json:"files"`
FileEntries []LocalModelFile `json:"file_entries,omitempty"`
DownloadedAt time.Time `json:"downloaded_at"`
Origin LocalModelOrigin `json:"origin,omitempty"`
Description string `json:"description,omitempty"`
License string `json:"license,omitempty"`
PipelineTag string `json:"pipeline_tag,omitempty"`
}
func LoadManifest ¶
func LoadManifest(baseDir, namespace, name string) (*LocalModel, error)
LoadManifest reads a model manifest from disk.
func (*LocalModel) FullName ¶
func (m *LocalModel) FullName() string
type LocalModelFile ¶
type LocalModelOrigin ¶
type LocalModelOrigin string
const ( LocalModelOriginUpload LocalModelOrigin = "upload" LocalModelOriginMarketplace LocalModelOrigin = "marketplace" )
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func (*Manager) Get ¶
func (m *Manager) Get(modelID string) (*LocalModel, error)
Get returns a locally downloaded model by ID.
func (*Manager) GetWithFileEntries ¶
func (m *Manager) GetWithFileEntries(modelID string) (*LocalModel, error)
GetWithFileEntries returns a local model with file-level metadata filled in.
func (*Manager) Import ¶
func (m *Manager) Import(opts ImportOptions) (*LocalModel, error)
Import copies a prepared local source into the managed model store and writes a fresh manifest.
func (*Manager) ImportPreparedDirectory ¶
func (m *Manager) ImportPreparedDirectory(opts ImportOptions) (*LocalModel, error)
ImportPreparedDirectory installs an already-staged directory into the managed model store without copying it through an additional prepared directory first.
func (*Manager) List ¶
func (m *Manager) List() ([]*LocalModel, error)
List returns all locally downloaded models.
func (*Manager) PublicModelID ¶
PublicModelID resolves a local model ID and returns its public inference ID.
func (*Manager) Pull ¶
func (m *Manager) Pull(ctx context.Context, modelID string, quants []string, progress csghub.SnapshotProgressFunc) (*LocalModel, error)
Pull downloads a model from CSGHub. quants selects GGUF weight variants when the repository exposes multiple quantizations (for example Q4_K_M or Q8_0). Empty quants keeps the default behavior (highest-precision GGUF variant). Non-GGUF models ignore quants.
func (*Manager) ResolveLocalModel ¶
func (m *Manager) ResolveLocalModel(modelID string) (*LocalModel, error)
ResolveLocalModel resolves a downloaded local model by full ID (namespace/name) or by short name (name only).