Documentation
¶
Index ¶
- Constants
- type ChunkRow
- type DB
- func (db *DB) BatchUpsertRecommendationHistory(rows []RecommendationHistoryRow) error
- func (db *DB) BestTransferHistory(host, tool string) (TransferHistoryRow, bool, error)
- func (db *DB) ClearChunksAndUpsertDownload(row DownloadRow) error
- func (db *DB) ClearHostCaps() error
- func (db *DB) Close() error
- func (db *DB) DeleteChunks(url, dest string) error
- func (db *DB) DeleteChunksTx(tx *sql.Tx, url, dest string) error
- func (db *DB) DeleteDownload(url, dest string) error
- func (db *DB) DeleteDownloadAndChunks(url, dest string) error
- func (db *DB) DeleteDownloadTx(tx *sql.Tx, url, dest string) error
- func (db *DB) DeleteDownloadsAndChunksByDest(dest string) error
- func (db *DB) DeleteHostCaps(host string) error
- func (db *DB) DeleteMetadata(downloadURL string) error
- func (db *DB) GetHostCaps(host string) (HostCaps, bool, error)
- func (db *DB) GetMetadata(downloadURL string) (*ModelMetadata, error)
- func (db *DB) GetMetadataByDest(dest string) (*ModelMetadata, error)
- func (db *DB) IncDownloadRetries(url, dest string, delta int64) error
- func (db *DB) InitChunksTable() error
- func (db *DB) InitHostCapsTable() error
- func (db *DB) InitMetadataTable() error
- func (db *DB) InitRecommendationHistoryTable() error
- func (db *DB) InitTransferHistoryTable() error
- func (db *DB) ListChunks(url, dest string) ([]ChunkRow, error)
- func (db *DB) ListDownloads() ([]DownloadRow, error)
- func (db *DB) ListHostCaps() ([]HostCaps, error)
- func (db *DB) ListMetadata(filters MetadataFilters) ([]ModelMetadata, error)
- func (db *DB) ListRecommendationHistory(limit int) ([]RecommendationHistoryRow, error)
- func (db *DB) ListTransferHistory() ([]TransferHistoryRow, error)
- func (db *DB) NotifyChange()
- func (db *DB) RecommendationHistoryFor(task, query, hardwareKey string) ([]RecommendationHistoryRow, error)
- func (db *DB) ReplaceDownloadDest(url, oldDest, newDest string) error
- func (db *DB) ReplaceDownloadURL(oldURL string, row DownloadRow) error
- func (db *DB) ResetActiveChunks(url, dest string) error
- func (db *DB) SearchMetadata(query string) ([]ModelMetadata, error)
- func (db *DB) Subscribe() (<-chan struct{}, func())
- func (db *DB) UpdateChunkSHA(url, dest string, idx int, sha string) error
- func (db *DB) UpdateChunkSHATx(tx *sql.Tx, url, dest string, idx int, sha string) error
- func (db *DB) UpdateChunkStatus(url, dest string, idx int, status string) error
- func (db *DB) UpdateChunkStatusTx(tx *sql.Tx, url, dest string, idx int, status string) error
- func (db *DB) UpdateDownloadStatus(url, dest, status, lastError string) error
- func (db *DB) UpdateMetadataUsage(downloadURL string) error
- func (db *DB) UpsertChunk(c ChunkRow) error
- func (db *DB) UpsertChunkTx(tx *sql.Tx, c ChunkRow) error
- func (db *DB) UpsertDownload(row DownloadRow) error
- func (db *DB) UpsertDownloadTx(tx *sql.Tx, row DownloadRow) error
- func (db *DB) UpsertHostCaps(host string, headOK, acceptRanges bool) error
- func (db *DB) UpsertMetadata(meta *ModelMetadata) error
- func (db *DB) UpsertMetadataTx(tx *sql.Tx, meta *ModelMetadata) error
- func (db *DB) UpsertRecommendationHistory(row RecommendationHistoryRow) error
- func (db *DB) UpsertTransferHistory(row TransferHistoryRow) error
- func (db *DB) WithTx(fn func(tx *sql.Tx) error) error
- type DownloadRow
- type HostCaps
- type MetadataFilters
- type ModelMetadata
- type RecommendationHistoryRow
- type TransferHistoryRow
Constants ¶
const SchemaVersion = 1
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
func (*DB) BatchUpsertRecommendationHistory ¶ added in v0.8.1
func (db *DB) BatchUpsertRecommendationHistory(rows []RecommendationHistoryRow) error
func (*DB) BestTransferHistory ¶ added in v0.8.1
func (db *DB) BestTransferHistory(host, tool string) (TransferHistoryRow, bool, error)
func (*DB) ClearChunksAndUpsertDownload ¶ added in v0.6.2
func (db *DB) ClearChunksAndUpsertDownload(row DownloadRow) error
func (*DB) ClearHostCaps ¶
ClearHostCaps deletes all host capabilities from the cache.
func (*DB) DeleteChunks ¶
DeleteChunks removes all chunk rows for a given url+dest pair.
func (*DB) DeleteDownload ¶
DeleteDownload removes a download row for the given url+dest.
func (*DB) DeleteDownloadAndChunks ¶ added in v0.6.2
func (*DB) DeleteDownloadTx ¶ added in v0.6.2
func (*DB) DeleteDownloadsAndChunksByDest ¶ added in v0.6.2
func (*DB) DeleteHostCaps ¶
DeleteHostCaps deletes a single host from the cache.
func (*DB) DeleteMetadata ¶ added in v0.6.1
DeleteMetadata removes metadata for a specific download URL
func (*DB) GetMetadata ¶ added in v0.6.1
func (db *DB) GetMetadata(downloadURL string) (*ModelMetadata, error)
GetMetadata retrieves metadata for a specific download URL
func (*DB) GetMetadataByDest ¶ added in v0.6.1
func (db *DB) GetMetadataByDest(dest string) (*ModelMetadata, error)
GetMetadataByDest retrieves metadata for a specific destination path This is optimized with an index for fast lookups by file path
func (*DB) IncDownloadRetries ¶
IncDownloadRetries increments the retries counter for a download row.
func (*DB) InitChunksTable ¶
func (*DB) InitHostCapsTable ¶
func (*DB) InitMetadataTable ¶ added in v0.6.1
InitMetadataTable creates the model_metadata table
func (*DB) InitRecommendationHistoryTable ¶ added in v0.8.1
func (*DB) InitTransferHistoryTable ¶ added in v0.8.1
func (*DB) ListDownloads ¶
func (db *DB) ListDownloads() ([]DownloadRow, error)
ListDownloads returns a snapshot of the downloads table
func (*DB) ListHostCaps ¶
ListHostCaps returns all cached host capabilities.
func (*DB) ListMetadata ¶ added in v0.6.1
func (db *DB) ListMetadata(filters MetadataFilters) ([]ModelMetadata, error)
ListMetadata retrieves metadata with optional filters
func (*DB) ListRecommendationHistory ¶ added in v0.8.1
func (db *DB) ListRecommendationHistory(limit int) ([]RecommendationHistoryRow, error)
func (*DB) ListTransferHistory ¶ added in v0.8.1
func (db *DB) ListTransferHistory() ([]TransferHistoryRow, error)
func (*DB) NotifyChange ¶ added in v0.6.2
func (db *DB) NotifyChange()
NotifyChange broadcasts a coalesced state-change signal to subscribers.
func (*DB) RecommendationHistoryFor ¶ added in v0.8.1
func (db *DB) RecommendationHistoryFor(task, query, hardwareKey string) ([]RecommendationHistoryRow, error)
func (*DB) ReplaceDownloadDest ¶ added in v0.6.2
ReplaceDownloadDest updates a download and related rows from a local staging path to a final destination identifier such as an s3:// URI.
func (*DB) ReplaceDownloadURL ¶ added in v0.6.2
func (db *DB) ReplaceDownloadURL(oldURL string, row DownloadRow) error
func (*DB) ResetActiveChunks ¶ added in v0.8.1
ResetActiveChunks marks in-flight chunk rows as pending so a canceled process can resume by refetching any chunk that may have been only partially written.
func (*DB) SearchMetadata ¶ added in v0.6.1
func (db *DB) SearchMetadata(query string) ([]ModelMetadata, error)
SearchMetadata performs a full-text search across model metadata
func (*DB) Subscribe ¶ added in v0.6.2
func (db *DB) Subscribe() (<-chan struct{}, func())
Subscribe returns a channel that receives a signal whenever DB state changes. Signals are coalesced when the receiver is slow.
func (*DB) UpdateChunkSHA ¶
func (*DB) UpdateChunkSHATx ¶
func (*DB) UpdateChunkStatus ¶
func (*DB) UpdateChunkStatusTx ¶
func (*DB) UpdateDownloadStatus ¶
UpdateDownloadStatus updates only status and last_error, preserving other fields.
func (*DB) UpdateMetadataUsage ¶ added in v0.6.1
UpdateMetadataUsage increments usage stats and updates last_used timestamp
func (*DB) UpsertChunk ¶
func (*DB) UpsertChunkTx ¶
Tx variants for grouping operations atomically
func (*DB) UpsertDownload ¶
func (db *DB) UpsertDownload(row DownloadRow) error
func (*DB) UpsertDownloadTx ¶ added in v0.6.2
func (db *DB) UpsertDownloadTx(tx *sql.Tx, row DownloadRow) error
func (*DB) UpsertHostCaps ¶
func (*DB) UpsertMetadata ¶ added in v0.6.1
func (db *DB) UpsertMetadata(meta *ModelMetadata) error
UpsertMetadata inserts or updates model metadata
func (*DB) UpsertMetadataTx ¶ added in v0.7.0
func (db *DB) UpsertMetadataTx(tx *sql.Tx, meta *ModelMetadata) error
func (*DB) UpsertRecommendationHistory ¶ added in v0.8.1
func (db *DB) UpsertRecommendationHistory(row RecommendationHistoryRow) error
func (*DB) UpsertTransferHistory ¶ added in v0.8.1
func (db *DB) UpsertTransferHistory(row TransferHistoryRow) error
type DownloadRow ¶
type MetadataFilters ¶ added in v0.6.1
type MetadataFilters struct {
Source string // Filter by source: "huggingface", "civitai", etc.
ModelType string // Filter by type: "LLM", "LoRA", "Checkpoint", etc.
Favorite bool // Show only favorites
MinRating int // Minimum user rating (1-5)
Tags []string // Filter by tags
OrderBy string // "last_used", "name", "size", "rating", "created_at"
Limit int // Limit results
}
MetadataFilters provides filtering options for ListMetadata
type ModelMetadata ¶ added in v0.6.1
type ModelMetadata struct {
ID int64 `json:"id"`
// Link to downloads table
DownloadURL string `json:"download_url"`
Dest string `json:"dest,omitempty"` // Destination file path
// Basic model info
ModelName string `json:"model_name,omitempty"`
ModelID string `json:"model_id,omitempty"` // e.g., "TheBloke/Llama-2-7B-GGUF"
Version string `json:"version,omitempty"` // e.g., "Q4_K_M", "fp16"
Source string `json:"source,omitempty"` // "huggingface", "civitai", "direct"
// Metadata
Description string `json:"description,omitempty"`
Author string `json:"author,omitempty"`
AuthorURL string `json:"author_url,omitempty"`
License string `json:"license,omitempty"`
Tags []string `json:"tags,omitempty"`
// Model specs
ModelType string `json:"model_type,omitempty"` // "LLM", "LoRA", "Checkpoint", "VAE", "Embedding"
BaseModel string `json:"base_model,omitempty"` // "llama-2", "sdxl", etc.
Architecture string `json:"architecture,omitempty"` // "transformer", "unet", etc.
ParameterCount string `json:"parameter_count,omitempty"` // "7B", "13B", "70B"
Quantization string `json:"quantization,omitempty"` // "Q4_K_M", "Q5_K_S", "fp16"
// File info
FileSize int64 `json:"file_size,omitempty"`
FileFormat string `json:"file_format,omitempty"` // "gguf", "safetensors", "ckpt", "bin"
// Usage stats
DownloadCount int `json:"download_count"`
LastUsed *time.Time `json:"last_used,omitempty"`
TimesUsed int `json:"times_used"`
// External links
HomepageURL string `json:"homepage_url,omitempty"`
RepoURL string `json:"repo_url,omitempty"`
DocumentationURL string `json:"documentation_url,omitempty"`
ThumbnailURL string `json:"thumbnail_url,omitempty"`
// Timestamps
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
// User data
UserNotes string `json:"user_notes,omitempty"`
UserRating int `json:"user_rating,omitempty"` // 1-5 stars
Favorite bool `json:"favorite"`
}
ModelMetadata stores rich metadata about downloaded models
type RecommendationHistoryRow ¶ added in v0.8.1
type RecommendationHistoryRow struct {
Task string `json:"task"`
Query string `json:"query"`
Provider string `json:"provider"`
ModelID string `json:"model_id"`
URI string `json:"uri"`
Action string `json:"action"`
Score int `json:"score"`
Fit string `json:"fit"`
HardwareKey string `json:"hardware_key"`
Count int `json:"count"`
LastSelected int64 `json:"last_selected,omitempty"`
LastSkipped int64 `json:"last_skipped,omitempty"`
LastShown int64 `json:"last_shown,omitempty"`
UpdatedAt int64 `json:"updated_at"`
}
type TransferHistoryRow ¶ added in v0.8.1
type TransferHistoryRow struct {
Host string `json:"host"`
Tool string `json:"tool"`
Connections int `json:"connections"`
ChunkSizeMB int `json:"chunk_size_mb"`
AvgBPS float64 `json:"avg_bps"`
Samples int `json:"samples"`
RateLimited bool `json:"rate_limited"`
LastStatus string `json:"last_status"`
LastError string `json:"last_error,omitempty"`
UpdatedAt int64 `json:"updated_at"`
}