Documentation
¶
Index ¶
- Constants
- 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 FindMMProjFiles(modelDir string) ([]string, error)
- func FindMTPFiles(modelDir string) ([]string, error)
- func FindWeightGGUFRelPaths(modelDir string) ([]string, error)
- func HasAudioOutputTokens(modelDir string) bool
- 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 IsTTSArchitecture(architecture string) bool
- func IsTTSModelFamily(name string) bool
- func IsTTSModelName(name 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 MaxModelLen(modelDir string, format Format) (int64, error)
- func ModelDir(baseDir, namespace, name string) string
- func PublicModelIDs(models []*LocalModel) map[string]string
- func RegistryModelDir(baseDir, artifactSource, namespace, name string) string
- func RemoveModelDir(baseDir, namespace, name string) error
- func RemoveRegistryModelDir(baseDir, artifactSource, namespace, name string) error
- func SaveManifest(baseDir string, m *LocalModel) error
- func SaveManifestInDir(modelDir string, m *LocalModel) error
- func TTSBackendFor(modelDir, modelName string) string
- func TTSBackendForMetadata(architecture, modelName string) string
- 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) PullFrom(ctx context.Context, modelID, sourceValue, revision string, quants []string, ...) (*LocalModel, error)
- func (m *Manager) Remove(modelID string) error
- func (m *Manager) RemovePartial(modelID, sourceValue string) (string, error)
- func (m *Manager) ResolveLocalModel(modelID string) (*LocalModel, error)
- func (m *Manager) ResolveLocalModelID(modelID string) (string, error)
Constants ¶
const ( TTSBackendQwen3 = "qwen3-tts" TTSBackendKokoro = "kokoro" TTSBackendTransformers = "transformers" TTSBackendVoxCPM = "voxcpm" )
TTS backend names reported by TTSBackendFor. They mirror the engines in internal/tts/worker/tts_worker.py; a model that matches none of them is a text-to-speech model the runtime cannot synthesise, and saying so is better than reporting support and failing at synthesis time.
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 in the model directory.
func FindMMProjFiles ¶ added in v0.9.37
FindMMProjFiles returns multimodal projector GGUF files ordered with conventionally named mmproj files first, then metadata-detected projectors.
func FindMTPFiles ¶ added in v0.9.37
FindMTPFiles returns Multi-Token Prediction companion GGUF files.
func FindWeightGGUFRelPaths ¶ added in v0.9.37
FindWeightGGUFRelPaths returns main-model GGUF paths while excluding filename- and metadata-identified companion modules.
func HasAudioOutputTokens ¶ added in v0.9.72
HasAudioOutputTokens reports whether the tokenizer in modelDir defines a matched pair of audio span tokens, which marks a model that generates audio codec tokens. Both ends are required: a generator needs to open and close the span, whereas an audio-input model may declare only a leading marker.
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 IsTTSArchitecture ¶ added in v0.9.70
IsTTSArchitecture reports whether the HuggingFace architecture is a text-to-speech model.
func IsTTSModelFamily ¶ added in v0.9.70
IsTTSModelFamily reports whether a model id/name belongs to a known text-to-speech family.
func IsTTSModelName ¶ added in v0.9.72
IsTTSModelName reports whether a model id or name marks itself as text-to-speech with a delimited "tts" token, such as Qwen3-0.6B-TTS. The family list cannot cover the long tail of fine-tunes that only say so in their name.
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 MaxModelLen ¶ added in v0.9.31
MaxModelLen returns the model's native maximum context length. GGUF models carry this value in their metadata header; SafeTensors models use the Hugging Face config.json stored alongside the weights.
func PublicModelIDs ¶
func PublicModelIDs(models []*LocalModel) map[string]string
PublicModelIDs returns stable short model IDs keyed by each model's full storage ID. OpenCSG and imported models preserve short IDs for compatibility; external registry models use source/namespace/name and therefore do not collide across registries.
func RegistryModelDir ¶ added in v0.9.53
RegistryModelDir keeps historical OpenCSG/import paths stable while namespacing external registries so identical repository IDs can coexist.
func RemoveModelDir ¶
RemoveModelDir removes the directory for a model.
func RemoveRegistryModelDir ¶ added in v0.9.53
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.
func TTSBackendFor ¶ added in v0.9.73
TTSBackendFor reports which text-to-speech backend can serve the model in modelDir, or "" when none can. The order matches load_engine() in tts_worker.py, and the two must stay in step: this decides what the library advertises, that decides what actually runs.
func TTSBackendForMetadata ¶ added in v0.9.73
TTSBackendForMetadata makes the same decision from hub metadata alone, for a model that has not been downloaded and so has no config.json to read. It keeps what the marketplace advertises in step with what the library reports once the model is on disk.
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"`
ArtifactSource string `json:"artifact_source,omitempty"`
Repository string `json:"repository,omitempty"`
RequestedRevision string `json:"requested_revision,omitempty"`
ResolvedRevision string `json:"resolved_revision,omitempty"`
}
func LoadManifest ¶
func LoadManifest(baseDir, namespace, name string) (*LocalModel, error)
LoadManifest reads a model manifest from disk.
func LoadManifestInDir ¶ added in v0.9.53
func LoadManifestInDir(modelDir string) (*LocalModel, error)
LoadManifestInDir reads a manifest from an already resolved model directory.
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) PullFrom ¶ added in v0.9.53
func (m *Manager) PullFrom(ctx context.Context, modelID, sourceValue, revision string, quants []string, progress csghub.SnapshotProgressFunc) (*LocalModel, error)
PullFrom downloads a model from an artifact registry. Empty source preserves the historical OpenCSG behavior.
func (*Manager) RemovePartial ¶ added in v0.9.53
RemovePartial removes an incomplete registry download without touching an installed model. It returns the removed directory for user-facing diagnostics.
func (*Manager) ResolveLocalModel ¶
func (m *Manager) ResolveLocalModel(modelID string) (*LocalModel, error)
ResolveLocalModel resolves a downloaded local model by storage ID ([source/]namespace/name) or by its public inference ID.