Documentation
¶
Overview ¶
Package discovery provides model discovery interfaces and implementations.
Index ¶
Constants ¶
const DefaultAPITTL = 60 * 60
DefaultAPITTL is 1 hour for API sources.
const DefaultGitHubTTL = 24 * 60 * 60
DefaultGitHubTTL is 24 hours for GitHub sources.
const GracePeriodDays = 7
GracePeriodDays is how long stale cache is considered valid.
Variables ¶
var GitHubSources = []SourceConfig{ { ProviderID: constant.GeminiCLI, URL: "https://raw.githubusercontent.com/google-gemini/gemini-cli/main/packages/core/src/config/models.ts", SourceType: "github", TTLSeconds: DefaultGitHubTTL, }, }
GitHubSources contains the verified GitHub URLs for CLI model discovery.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache provides file-based caching for discovered models.
func NewCache ¶
NewCache creates a new cache with the given directory. If the directory does not exist, it will be created.
func (*Cache) Get ¶
func (c *Cache) Get(providerID string) *CacheEntry
Get retrieves a cached entry for the given provider. Returns nil if not found or expired.
func (*Cache) GetWithGrace ¶
func (c *Cache) GetWithGrace(providerID string, graceDays int) *CacheEntry
GetWithGrace retrieves a cached entry, allowing grace period for stale data. graceDays specifies how many days old the cache can be before it's rejected.
func (*Cache) Set ¶
func (c *Cache) Set(entry *CacheEntry) error
Set stores a cache entry for the given provider.
type CacheEntry ¶
type CacheEntry struct {
ProviderID string `json:"provider_id"`
FetchedAt time.Time `json:"fetched_at"`
TTLSeconds int `json:"ttl_seconds"`
Models []*registry.ModelInfo `json:"models"`
SourceURL string `json:"source_url,omitempty"`
SourceType string `json:"source_type"` // "github" or "api"
}
CacheEntry represents a cached discovery result.
type Discoverer ¶
type Discoverer struct {
// contains filtered or unexported fields
}
Discoverer orchestrates model discovery from multiple sources.
func NewDiscoverer ¶
func NewDiscoverer(cacheDir string) (*Discoverer, error)
NewDiscoverer creates a new Discoverer with the given cache directory.
func (*Discoverer) AddSource ¶
func (d *Discoverer) AddSource(src SourceConfig)
AddSource adds a new discovery source dynamically.
func (*Discoverer) DiscoverAll ¶
DiscoverAll runs discovery for all configured sources. Returns a map of provider ID to discovered models.
func (*Discoverer) GetCachedModels ¶
func (d *Discoverer) GetCachedModels(providerID string) []*registry.ModelInfo
GetCachedModels returns cached models for a provider if available.
type Fetcher ¶
type Fetcher interface {
// Fetch retrieves the content from the given URL.
Fetch(ctx context.Context, url string) ([]byte, error)
}
Fetcher is the interface for retrieving raw content from a remote source (URL).
type ModelDiscoverer ¶
type ModelDiscoverer interface {
// Discover returns a list of available models.
Discover(ctx context.Context) ([]*registry.ModelInfo, error)
// ProviderID returns the identifier for this discoverer's provider.
ProviderID() string
}
ModelDiscoverer is the interface that all discovery strategies must implement. It returns a list of discovered model definitions.