Documentation
¶
Overview ¶
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),
)
Package starmap provides a unified AI model catalog system with automatic updates, event hooks, and support for multiple storage backends.
Index ¶
- type AutoUpdateFunc
- type AutoUpdater
- type Catalog
- type Client
- type Hooks
- type ModelAddedHook
- type ModelRemovedHook
- type ModelUpdatedHook
- type Option
- func WithAutoUpdateFunc(fn AutoUpdateFunc) Option
- func WithAutoUpdateInterval(interval time.Duration) Option
- func WithAutoUpdatesDisabled() Option
- func WithEmbeddedCatalog() Option
- func WithLocalPath(path string) Option
- func WithRemoteServerAPIKey(apiKey string) Option
- func WithRemoteServerOnly(url string) Option
- func WithRemoteServerURL(url string) Option
- type Persistence
- type Updater
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 AutoUpdater ¶ added in v0.0.15
type AutoUpdater interface {
// AutoUpdatesOn begins automatic updates if configured
AutoUpdatesOn() error
// AutoUpdatesOff stops automatic updates
AutoUpdatesOff() error
}
AutoUpdater provides controls for automatic catalog updates.
type Client ¶ added in v0.0.15
type Client interface {
// Catalog provides copy-on-read access to the catalog
Catalog
// Updater handles catalog update and sync operations
Updater
// Persistence handles catalog persistence operations
Persistence
// AutoUpdater provides access to automatic update controls
AutoUpdater
// Hooks provides access to event callback registration
Hooks
}
Client manages a catalog with automatic updates and event hooks.
type Hooks ¶ added in v0.0.15
type Hooks interface {
// 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)
}
Hooks provides event callback registration for catalog changes.
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 WithAutoUpdatesDisabled ¶ added in v0.0.15
func WithAutoUpdatesDisabled() Option
WithAutoUpdatesDisabled configures whether automatic updates are disabled.
func WithEmbeddedCatalog ¶ added in v0.0.15
func WithEmbeddedCatalog() Option
WithEmbeddedCatalog configures whether to use an embedded catalog. It defaults to false, but takes precedence over WithLocalPath if set.
func WithLocalPath ¶
WithLocalPath configures the local source to use a specific catalog path.
func WithRemoteServerAPIKey ¶ added in v0.0.15
WithRemoteServerAPIKey configures the remote server API key.
func WithRemoteServerOnly ¶
WithRemoteServerOnly configures whether to only use the remote server and not hit provider APIs.
func WithRemoteServerURL ¶ added in v0.0.15
WithRemoteServerURL configures the remote server URL.
type Persistence ¶ added in v0.0.15
Persistence handles catalog persistence operations.
type Updater ¶ added in v0.0.15
type Updater interface {
// Sync synchronizes the catalog with provider APIs
Sync(ctx context.Context, opts ...sync.Option) (*sync.Result, error)
// Update manually triggers a catalog update
Update(ctx context.Context) error
}
Updater handles catalog synchronization operations.
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/app
Package app provides the application context and dependency management for the starmap CLI.
|
Package app provides the application context and dependency management for the starmap CLI. |
|
starmap/cmd/auth
Package auth provides cloud provider authentication helpers for Starmap.
|
Package auth provides cloud provider authentication helpers for Starmap. |
|
starmap/cmd/authors
Package authors provides the authors resource command.
|
Package authors provides the authors resource command. |
|
starmap/cmd/completion
Package completion provides shell completion management commands.
|
Package completion provides shell completion management commands. |
|
starmap/cmd/deps
Package deps provides commands for managing external dependencies required by data sources.
|
Package deps provides commands for managing external dependencies required by data sources. |
|
starmap/cmd/embed
Package embed provides commands for exploring the embedded filesystem.
|
Package embed provides commands for exploring the embedded filesystem. |
|
starmap/cmd/models
Package models provides the models resource command and subcommands.
|
Package models provides the models resource command and subcommands. |
|
starmap/cmd/providers
Package providers provides the providers resource command and subcommands.
|
Package providers provides the providers resource command and subcommands. |
|
starmap/cmd/serve
Package serve provides HTTP server commands for the Starmap CLI.
|
Package serve provides HTTP server commands for the Starmap CLI. |
|
starmap/cmd/update
Package update provides the update command implementation.
|
Package update provides the update command implementation. |
|
starmap/cmd/validate
Package validate provides catalog validation commands.
|
Package validate provides catalog validation commands. |
|
internal
|
|
|
attribution
Package attribution provides model-to-author mapping functionality across multiple providers.
|
Package attribution provides model-to-author mapping functionality across multiple providers. |
|
auth
Package auth provides authentication checking for AI model providers.
|
Package auth provides authentication checking for AI model providers. |
|
auth/adc
Package adc handles Google Application Default Credentials.
|
Package adc handles Google Application Default Credentials. |
|
cmd/alerts
Package alerts provides a structured system for status notifications.
|
Package alerts provides a structured system for status notifications. |
|
cmd/application
Package application provides the application interface for Starmap commands.
|
Package application provides the application interface 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/embed
Package embed provides utilities for working with the embedded filesystem.
|
Package embed provides utilities for working with the embedded filesystem. |
|
cmd/emoji
Package emoji provides symbol constants for CLI output.
|
Package emoji provides symbol constants for CLI output. |
|
cmd/filter
Package filter provides model filtering functionality for starmap commands.
|
Package filter provides model filtering functionality for starmap commands. |
|
cmd/format
Package format provides formatters for command output.
|
Package format provides formatters for command output. |
|
cmd/globals
Package globals provides shared flag structures and utilities for CLI commands.
|
Package globals provides shared flag structures and utilities for CLI commands. |
|
cmd/hints
Package hints provides formatting for hints in different output formats.
|
Package hints provides formatting for hints in different output formats. |
|
cmd/notify
Package notify provides context detection for smart hint generation.
|
Package notify provides context detection for smart hint generation. |
|
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. |
|
deps
Package deps provides dependency checking and management for sources.
|
Package deps provides dependency checking and management for sources. |
|
embedded/openapi
Package openapi embeds the OpenAPI 3.0 specification files for the Starmap HTTP API.
|
Package openapi embeds the OpenAPI 3.0 specification files for the Starmap HTTP API. |
|
matcher
Package matcher provides a unified interface for pattern matching using glob and regex patterns.
|
Package matcher provides a unified interface for pattern matching using glob and regex patterns. |
|
server
Package server provides HTTP server implementation for the Starmap API.
|
Package server provides HTTP server implementation for the Starmap API. |
|
server/cache
Package cache provides an in-memory caching layer for the HTTP server.
|
Package cache provides an in-memory caching layer for the HTTP server. |
|
server/events
Package events provides a unified event system for real-time catalog updates.
|
Package events provides a unified event system for real-time catalog updates. |
|
server/events/adapters
Package adapters provides transport-specific implementations of the Subscriber interface.
|
Package adapters provides transport-specific implementations of the Subscriber interface. |
|
server/filter
Package filter provides query parameter parsing and filtering for API endpoints.
|
Package filter provides query parameter parsing and filtering for API endpoints. |
|
server/handlers
Package handlers provides HTTP request handlers for the Starmap API.
|
Package handlers provides HTTP request handlers for the Starmap API. |
|
server/middleware
Package middleware provides HTTP middleware for the Starmap API server.
|
Package middleware provides HTTP middleware for the Starmap API server. |
|
server/response
Package response provides standardized HTTP response structures and helpers for the Starmap API server.
|
Package response provides standardized HTTP response structures and helpers for the Starmap API server. |
|
server/sse
Package sse provides Server-Sent Events support for real-time updates.
|
Package sse provides Server-Sent Events support for real-time updates. |
|
server/websocket
Package websocket provides WebSocket support for real-time catalog updates.
|
Package websocket provides WebSocket support for real-time catalog updates. |
|
sources/clients
Package clients provides provider client registry functions.
|
Package clients provides provider client registry functions. |
|
sources/providers/anthropic
Package anthropic provides a client for the Anthropic API.
|
Package anthropic provides a client for the Anthropic API. |
|
sources/providers/google
Package google provides a unified, dynamic client for Google AI APIs (AI Studio and Vertex AI).
|
Package google provides a unified, dynamic client for Google AI APIs (AI Studio and Vertex AI). |
|
sources/providers/openai
Package openai provides a unified, dynamic client for OpenAI-compatible APIs.
|
Package openai provides a unified, dynamic client for OpenAI-compatible APIs. |
|
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. |
|
utils/ptr
Package ptr provides utility functions for creating pointers to values.
|
Package ptr provides utility functions for creating pointers to values. |
|
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. |
|
save
Package save provides options and utilities for saving catalogs in various formats.
|
Package save provides options and utilities for saving catalogs in various formats. |
|
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. |
|
sync
Package sync provides options and utilities for synchronizing the catalog with provider APIs.
|
Package sync provides options and utilities for synchronizing the catalog with provider APIs. |
|
types
Package types provides shared type definitions used across the starmap packages.
|
Package types provides shared type definitions used across the starmap packages. |