Documentation
¶
Overview ¶
Package starmap provides a unified AI model catalog system with automatic updates, event hooks, and support for multiple storage backends.
Package starmap provides the main entry point for the Starmap AI model catalog system. It offers a high-level interface for managing AI model catalogs with automatic updates, event hooks, and provider synchronization capabilities.
Starmap wraps the underlying catalog system with additional features including: - Automatic background synchronization with provider APIs - Event hooks for model changes (added, updated, removed) - Thread-safe catalog access with copy-on-read semantics - Flexible configuration through functional options - Support for multiple data sources and merge strategies
Example usage:
// Create a starmap instance with default settings
sm, err := starmap.New()
if err != nil {
log.Fatal(err)
}
defer sm.AutoUpdatesOff()
// Register event hooks
sm.OnModelAdded(func(model catalogs.Model) {
log.Printf("New model: %s", model.ID)
})
// Get catalog (returns a copy for thread safety)
catalog, err := sm.Catalog()
if err != nil {
log.Fatal(err)
}
// Access models
models := catalog.Models()
for _, model := range models.List() {
fmt.Printf("Model: %s - %s\n", model.ID, model.Name)
}
// Manually trigger sync
result, err := sm.Sync(ctx, WithProviders("openai", "anthropic"))
if err != nil {
log.Fatal(err)
}
// Configure with custom options
sm, err = starmap.New(
WithAutoUpdateInterval(30 * time.Minute),
WithLocalPath("./custom-catalog"),
WithAutoUpdates(true),
)
Index ¶
- type AutoUpdateFunc
- type ModelAddedHook
- type ModelRemovedHook
- type ModelUpdatedHook
- type Option
- func WithAutoUpdateFunc(fn AutoUpdateFunc) Option
- func WithAutoUpdateInterval(interval time.Duration) Option
- func WithAutoUpdates(enabled bool) Option
- func WithInitialCatalog(catalog catalogs.Catalog) Option
- func WithLocalPath(path string) Option
- func WithRemoteServer(url string, apiKey *string) Option
- func WithRemoteServerOnly(enabled bool) Option
- type Starmap
- type SyncOption
- func WithAutoApprove(autoApprove bool) SyncOption
- func WithCleanModelsDevRepo(cleanup bool) SyncOption
- func WithDryRun(dryRun bool) SyncOption
- func WithFailFast(failFast bool) SyncOption
- func WithFresh(fresh bool) SyncOption
- func WithOutputPath(path string) SyncOption
- func WithProvider(providerID catalogs.ProviderID) SyncOption
- func WithReformat(reformat bool) SyncOption
- func WithSources(types ...sources.Type) SyncOption
- func WithTimeout(timeout time.Duration) SyncOption
- type SyncOptions
- type SyncProviderResult
- type SyncResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AutoUpdateFunc ¶
AutoUpdateFunc is a function that updates the catalog.
type ModelAddedHook ¶
ModelAddedHook is called when a model is added to the catalog.
type ModelRemovedHook ¶
ModelRemovedHook is called when a model is removed from the catalog.
type ModelUpdatedHook ¶
ModelUpdatedHook is called when a model is updated in the catalog.
type Option ¶
type Option func(*options) error
Option is a function that configures a Starmap instance.
func WithAutoUpdateFunc ¶
func WithAutoUpdateFunc(fn AutoUpdateFunc) Option
WithAutoUpdateFunc configures a custom function for updating the catalog.
func WithAutoUpdateInterval ¶
WithAutoUpdateInterval configures how often to automatically update the catalog.
func WithAutoUpdates ¶
WithAutoUpdates configures whether automatic updates are enabled.
func WithInitialCatalog ¶
WithInitialCatalog configures the initial catalog to use.
func WithLocalPath ¶
WithLocalPath configures the local source to use a specific catalog path.
func WithRemoteServer ¶
WithRemoteServer configures the remote server for catalog updates. A url is required, an api key can be provided for authentication, otherwise use nil to skip Bearer token authentication.
func WithRemoteServerOnly ¶
WithRemoteServerOnly configures whether to only use the remote server and not hit provider APIs.
type Starmap ¶
type Starmap interface {
// Catalog returns a copy of the current catalog
Catalog() (catalogs.Catalog, error)
// AutoUpdatesOn begins automatic updates if configured
AutoUpdatesOn() error
// AutoUpdatesOff stops automatic updates
AutoUpdatesOff() error
// Update manually triggers a catalog update
Update(ctx context.Context) error
// Sync synchronizes the catalog with provider APIs
Sync(ctx context.Context, opts ...SyncOption) (*SyncResult, error)
// OnModelAdded registers a callback for when models are added
OnModelAdded(ModelAddedHook)
// OnModelUpdated registers a callback for when models are updated
OnModelUpdated(ModelUpdatedHook)
// OnModelRemoved registers a callback for when models are removed
OnModelRemoved(ModelRemovedHook)
// Write saves the current catalog to disk
Write() error
}
Starmap manages a catalog with automatic updates and event hooks.
type SyncOption ¶
type SyncOption func(*SyncOptions)
SyncOption is a function that configures SyncOptions.
func WithAutoApprove ¶
func WithAutoApprove(autoApprove bool) SyncOption
WithAutoApprove configures auto approval.
func WithCleanModelsDevRepo ¶
func WithCleanModelsDevRepo(cleanup bool) SyncOption
WithCleanModelsDevRepo configures whether to remove temporary models.dev repository after update.
func WithFailFast ¶
func WithFailFast(failFast bool) SyncOption
WithFailFast configures fail-fast behavior.
func WithFresh ¶
func WithFresh(fresh bool) SyncOption
WithFresh configures whether to delete existing models and fetch fresh from APIs.
func WithOutputPath ¶
func WithOutputPath(path string) SyncOption
WithOutputPath configures the output path for saving.
func WithProvider ¶
func WithProvider(providerID catalogs.ProviderID) SyncOption
WithProvider configures syncing for a specific provider only.
func WithReformat ¶
func WithReformat(reformat bool) SyncOption
WithReformat configures whether to reformat providers.yaml file even without changes.
func WithSources ¶
func WithSources(types ...sources.Type) SyncOption
WithSources configures which sources to use.
func WithTimeout ¶
func WithTimeout(timeout time.Duration) SyncOption
WithTimeout configures the sync timeout.
type SyncOptions ¶
type SyncOptions struct {
// Orchestration control
DryRun bool // Show changes without applying them
AutoApprove bool // Skip confirmation prompts
FailFast bool // Stop on first source error instead of continuing
Timeout time.Duration // Timeout for the entire sync operation
// Source selection
Sources []sources.Type // Which sources to use (empty means all)
ProviderID *catalogs.ProviderID // Filter for specific provider
// Output control (used AFTER merging)
OutputPath string // Where to save final catalog (empty means default location)
// Source behavior control
Fresh bool // Delete existing models and fetch fresh from APIs (destructive)
CleanModelsDevRepo bool // Remove temporary models.dev repository after update
Reformat bool // Reformat providers.yaml file even without changes
}
SyncOptions controls the overall sync orchestration in Starmap.Sync().
func NewSyncOptions ¶
func NewSyncOptions(opts ...SyncOption) *SyncOptions
NewSyncOptions returns sync options with default values.
func (*SyncOptions) SourceOptions ¶
func (s *SyncOptions) SourceOptions() []sources.Option
SourceOptions converts sync options to properly typed source options.
type SyncProviderResult ¶
type SyncProviderResult struct {
ProviderID catalogs.ProviderID // The provider that was synced
Added []catalogs.Model // New models not in catalog
Updated []differ.ModelUpdate // Existing models with changes
Removed []catalogs.Model // Models in catalog but not in API (informational only)
// Summary counts
AddedCount int // Number of models added
UpdatedCount int // Number of models updated
RemovedCount int // Number of models removed from API (not deleted from catalog)
// Metadata
APIModelsCount int // Total models fetched from API
ExistingModelsCount int // Total models that existed in catalog
EnhancedCount int // Number of models enhanced with models.dev data
}
SyncProviderResult represents sync results for a single provider.
func NewSyncProviderResult ¶
func NewSyncProviderResult(providerID catalogs.ProviderID) *SyncProviderResult
NewSyncProviderResult creates a new SyncProviderResult.
func (*SyncProviderResult) HasChanges ¶
func (spr *SyncProviderResult) HasChanges() bool
HasChanges returns true if the provider result contains any changes.
func (*SyncProviderResult) Summary ¶
func (spr *SyncProviderResult) Summary() string
Summary returns a human-readable summary of the provider result.
type SyncResult ¶
type SyncResult struct {
// Overall statistics
TotalChanges int // Total number of changes across all providers
ProvidersChanged int // Number of providers with changes
ProviderResults map[catalogs.ProviderID]*SyncProviderResult // Results per provider
// Operation metadata
DryRun bool // Whether this was a dry run
Fresh bool // Whether this was a fresh sync
OutputDir string // Where files were written (empty means default)
}
SyncResult represents the complete result of a sync operation.
func NewSyncResult ¶
func NewSyncResult() *SyncResult
NewSyncResult creates a new Result with initialized maps.
func (*SyncResult) HasChanges ¶
func (sr *SyncResult) HasChanges() bool
HasChanges returns true if the sync result contains any changes.
func (*SyncResult) Summary ¶
func (sr *SyncResult) Summary() string
Summary returns a human-readable summary of the sync result.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
starmap
command
Package main provides the entry point for the starmap CLI tool.
|
Package main provides the entry point for the starmap CLI tool. |
|
starmap/cmd
Package cmd provides the main command structure for the starmap CLI.
|
Package cmd provides the main command structure for the starmap CLI. |
|
starmap/cmd/fetch
Package fetch provides commands for fetching starmap resources from provider APIs.
|
Package fetch provides commands for fetching starmap resources from provider APIs. |
|
starmap/cmd/generate
Package generate provides commands for generating documentation and site content.
|
Package generate provides commands for generating documentation and site content. |
|
starmap/cmd/install
Package install provides commands for installing starmap components.
|
Package install provides commands for installing starmap components. |
|
starmap/cmd/list
Package list provides commands for listing starmap resources.
|
Package list provides commands for listing starmap resources. |
|
starmap/cmd/serve
Package serve provides HTTP server commands.
|
Package serve provides HTTP server commands. |
|
starmap/cmd/uninstall
Package uninstall provides commands for uninstalling starmap components.
|
Package uninstall provides commands for uninstalling starmap components. |
|
starmap/cmd/update
Package update provides the update command implementation.
|
Package update provides the update command implementation. |
|
internal
|
|
|
cmd/catalog
Package catalog provides common catalog operations for CLI commands.
|
Package catalog provides common catalog operations for CLI commands. |
|
cmd/cmdutil
Package cmdutil provides shared flags and configuration utilities for starmap commands.
|
Package cmdutil provides shared flags and configuration utilities for starmap commands. |
|
cmd/completion
Package completion provides shared utilities for completion management.
|
Package completion provides shared utilities for completion management. |
|
cmd/constants
Package constants provides shared constants for CLI commands.
|
Package constants provides shared constants for CLI commands. |
|
cmd/filter
Package filter provides model filtering functionality for starmap commands.
|
Package filter provides model filtering functionality for starmap commands. |
|
cmd/output
Package output provides formatters for command output.
|
Package output provides formatters for command output. |
|
cmd/provider
Package provider provides common provider operations for CLI commands.
|
Package provider provides common provider operations for CLI commands. |
|
cmd/table
Package table provides common table formatting utilities for CLI commands.
|
Package table provides common table formatting utilities for CLI commands. |
|
sources/providers/anthropic
Package anthropic provides a client for the Anthropic API.
|
Package anthropic provides a client for the Anthropic API. |
|
sources/providers/baseclient
Package baseclient provides base client implementations for various providers.
|
Package baseclient provides base client implementations for various providers. |
|
sources/providers/cerebras
Package cerebras provides a client for the Cerebras API.
|
Package cerebras provides a client for the Cerebras API. |
|
sources/providers/deepseek
Package deepseek provides a client for interacting with the DeepSeek API.
|
Package deepseek provides a client for interacting with the DeepSeek API. |
|
sources/providers/google-ai-studio
Package googleaistudio provides a client for interacting with the Google AI Studio API.
|
Package googleaistudio provides a client for interacting with the Google AI Studio API. |
|
sources/providers/google-vertex
Package googlevertex provides a client for interacting with the Google Vertex AI API.
|
Package googlevertex provides a client for interacting with the Google Vertex AI API. |
|
sources/providers/groq
Package groq provides a client for the Groq API.
|
Package groq provides a client for the Groq API. |
|
sources/providers/openai
Package openai provides a client for the OpenAI API.
|
Package openai provides a client for the OpenAI API. |
|
sources/providers/testhelper
Package testhelper provides utilities for managing testdata files in provider tests.
|
Package testhelper provides utilities for managing testdata files in provider tests. |
|
sources/registry
Package registry provides provider client registry functions.
|
Package registry provides provider client registry functions. |
|
tools/site
Package site provides Hugo-based static site generation for Starmap documentation
|
Package site provides Hugo-based static site generation for Starmap documentation |
|
pkg
|
|
|
authority
Package authority manages source authority for catalog data reconciliation.
|
Package authority manages source authority for catalog data reconciliation. |
|
catalogs
Package catalogs provides the core catalog system for managing AI model metadata.
|
Package catalogs provides the core catalog system for managing AI model metadata. |
|
constants
Package constants provides shared constants used throughout the starmap codebase.
|
Package constants provides shared constants used throughout the starmap codebase. |
|
differ
Package differ provides functionality for comparing catalogs and detecting changes.
|
Package differ provides functionality for comparing catalogs and detecting changes. |
|
enhancer
Package enhancer provides functionality to enrich model data with metadata from external sources.
|
Package enhancer provides functionality to enrich model data with metadata from external sources. |
|
errors
Package errors provides custom error types for the starmap system.
|
Package errors provides custom error types for the starmap system. |
|
logging
Package logging provides structured logging for the starmap system using zerolog.
|
Package logging provides structured logging for the starmap system using zerolog. |
|
provenance
Package provenance provides field-level tracking of data sources and modifications.
|
Package provenance provides field-level tracking of data sources and modifications. |
|
reconciler
Package reconciler provides catalog synchronization and reconciliation capabilities.
|
Package reconciler provides catalog synchronization and reconciliation capabilities. |
|
sources
Package sources provides public APIs for working with AI model data sources.
|
Package sources provides public APIs for working with AI model data sources. |