Documentation
¶
Index ¶
- Constants
- func ConvertToStarmapModel(mdModel Model) *catalogs.Model
- func CopyAuthorLogos(outputDir string, authors []catalogs.Author, providers *catalogs.Providers) error
- func CopyProviderLogos(outputDir string, providers []*catalogs.Provider) error
- type API
- type Catalog
- func (c *Catalog) Author(id catalogs.AuthorID) (*catalogs.Author, error)
- func (c *Catalog) Authors() *catalogs.Authors
- func (c *Catalog) DeleteAuthor(id catalogs.AuthorID) error
- func (c *Catalog) DeleteEndpoint(id string) error
- func (c *Catalog) DeleteProvider(id catalogs.ProviderID) error
- func (c *Catalog) Endpoint(id string) (*catalogs.Endpoint, error)
- func (c *Catalog) Endpoints() *catalogs.Endpoints
- func (c *Catalog) Provider(id catalogs.ProviderID) (*catalogs.Provider, error)
- func (c *Catalog) Providers() *catalogs.Providers
- func (c *Catalog) SetAuthor(author catalogs.Author) error
- func (c *Catalog) SetEndpoint(endpoint catalogs.Endpoint) error
- func (c *Catalog) SetProvider(provider catalogs.Provider) error
- type Client
- type Cost
- type GitClient
- type GitSource
- func (s *GitSource) Catalog() catalogs.Catalog
- func (s *GitSource) Cleanup() error
- func (s *GitSource) Dependencies() []sources.Dependency
- func (s *GitSource) Fetch(ctx context.Context, _ ...sources.Option) error
- func (s *GitSource) ID() sources.ID
- func (s *GitSource) IsOptional() bool
- func (s *GitSource) Name() string
- func (s *GitSource) Setup(providers *catalogs.Providers) error
- type GitSourceOption
- type HTTPClient
- type HTTPSource
- func (s *HTTPSource) Catalog() catalogs.Catalog
- func (s *HTTPSource) Cleanup() error
- func (s *HTTPSource) Dependencies() []sources.Dependency
- func (s *HTTPSource) Fetch(ctx context.Context, _ ...sources.Option) error
- func (s *HTTPSource) ID() sources.ID
- func (s *HTTPSource) IsOptional() bool
- func (s *HTTPSource) Name() string
- func (s *HTTPSource) Setup(providers *catalogs.Providers) error
- type HTTPSourceOption
- type Limit
- type Modalities
- type Model
- type Provider
Constants ¶
const ( // ModelsDevRepoURL is the URL for the models.dev git repository. ModelsDevRepoURL = "https://github.com/sst/models.dev.git" // DefaultBranch is the default branch to use for models.dev. DefaultBranch = "dev" )
const ( // ModelsDevAPIURL is the URL for the models.dev API. ModelsDevAPIURL = "https://models.dev/api.json" // HTTPCacheTTL is the cache time-to-live for HTTP responses. HTTPCacheTTL = 1 * time.Hour )
Variables ¶
This section is empty.
Functions ¶
func ConvertToStarmapModel ¶
ConvertToStarmapModel converts a models.dev model to a starmap model. This is shared between GitSource and HTTPSource to avoid duplication.
func CopyAuthorLogos ¶ added in v0.0.20
func CopyAuthorLogos(outputDir string, authors []catalogs.Author, providers *catalogs.Providers) error
CopyAuthorLogos copies author logos from models.dev provider logos to author directories. Since models.dev doesn't have a separate authors directory, we copy from the provider directory when the author ID matches a provider ID (or alias).
Types ¶
type API ¶
API represents the structure of models.dev api.json.
func (*API) GetProvider ¶
func (api *API) GetProvider(providerID catalogs.ProviderID) (*Provider, bool)
GetProvider returns a specific provider from the API data.
type Catalog ¶
type Catalog struct {
// contains filtered or unexported fields
}
Catalog implements starmap.Catalog interface for models.dev data.
func NewCatalog ¶
NewCatalog creates a new models.dev catalog from parsed API data.
func (*Catalog) DeleteAuthor ¶
DeleteAuthor implements starmap.Catalog.
func (*Catalog) DeleteEndpoint ¶
DeleteEndpoint implements starmap.Catalog.
func (*Catalog) DeleteProvider ¶
func (c *Catalog) DeleteProvider(id catalogs.ProviderID) error
DeleteProvider implements starmap.Catalog.
func (*Catalog) SetEndpoint ¶
SetEndpoint implements starmap.Catalog.
type Cost ¶
type Cost struct {
Input *float64 `json:"input,omitempty"`
Output *float64 `json:"output,omitempty"`
Cache *float64 `json:"cache,omitempty"` // Legacy cache field
CacheRead *float64 `json:"cache_read,omitempty"` // Cache read costs
CacheWrite *float64 `json:"cache_write,omitempty"` // Cache write costs
}
Cost represents pricing information.
type GitClient ¶
type GitClient struct {
RepoPath string
}
GitClient handles models.dev repository operations.
func NewGitClient ¶
NewGitClient creates a new models.dev git client.
func (*GitClient) EnsureRepository ¶
EnsureRepository ensures the models.dev repository is available and up to date.
func (*GitClient) GetAPIPath ¶
GetAPIPath returns the path to the generated api.json file.
func (*GitClient) GetProvidersPath ¶
GetProvidersPath returns the path to the providers directory.
type GitSource ¶
type GitSource struct {
// contains filtered or unexported fields
}
GitSource enhances models with models.dev data.
func NewGitSource ¶
func NewGitSource(opts ...GitSourceOption) *GitSource
NewGitSource creates a new models.dev git source.
func (*GitSource) Dependencies ¶ added in v0.0.17
func (s *GitSource) Dependencies() []sources.Dependency
Dependencies returns the list of external dependencies required by this source. Git source requires bun (for building) and git (for cloning).
func (*GitSource) Fetch ¶
Fetch creates a catalog with models that have pricing/limits data from models.dev.
func (*GitSource) IsOptional ¶ added in v0.0.17
IsOptional returns whether this source is optional. Git source is optional - HTTP source provides the same data without dependencies.
type GitSourceOption ¶ added in v0.0.10
type GitSourceOption func(*GitSource)
GitSourceOption configures a GitSource.
func WithGitSourcesDir ¶ added in v0.0.10
func WithGitSourcesDir(dir string) GitSourceOption
WithGitSourcesDir is an alias for WithSourcesDir for backward compatibility.
func WithSourcesDir ¶ added in v0.0.10
func WithSourcesDir(dir string) GitSourceOption
WithSourcesDir configures the sources directory for the git source.
type HTTPClient ¶
HTTPClient handles HTTP downloading of models.dev api.json.
func NewHTTPClient ¶
func NewHTTPClient(outputDir string) *HTTPClient
NewHTTPClient creates a new models.dev HTTP client.
func (*HTTPClient) Cleanup ¶
func (c *HTTPClient) Cleanup() error
Cleanup removes the cache directory.
func (*HTTPClient) EnsureAPI ¶
func (c *HTTPClient) EnsureAPI(ctx context.Context) error
EnsureAPI ensures the api.json is available and up to date.
func (*HTTPClient) GetAPIPath ¶
func (c *HTTPClient) GetAPIPath() string
GetAPIPath returns the path to the cached api.json file.
type HTTPSource ¶
type HTTPSource struct {
// contains filtered or unexported fields
}
HTTPSource enhances models with models.dev data via HTTP.
func NewHTTPSource ¶
func NewHTTPSource(opts ...HTTPSourceOption) *HTTPSource
NewHTTPSource creates a new models.dev HTTP source.
func (*HTTPSource) Catalog ¶
func (s *HTTPSource) Catalog() catalogs.Catalog
Catalog returns the catalog of this source.
func (*HTTPSource) Dependencies ¶ added in v0.0.17
func (s *HTTPSource) Dependencies() []sources.Dependency
Dependencies returns the list of external dependencies. HTTP source has no external dependencies.
func (*HTTPSource) Fetch ¶
Fetch creates a catalog with models that have pricing/limits data from models.dev.
func (*HTTPSource) ID ¶ added in v0.0.15
func (s *HTTPSource) ID() sources.ID
ID returns the ID of this source.
func (*HTTPSource) IsOptional ¶ added in v0.0.17
func (s *HTTPSource) IsOptional() bool
IsOptional returns whether this source is optional. HTTP source is optional - git source provides same data, and we can work without models.dev.
func (*HTTPSource) Name ¶ added in v0.0.17
func (s *HTTPSource) Name() string
Name returns the human-friendly name of this source.
type HTTPSourceOption ¶ added in v0.0.10
type HTTPSourceOption func(*HTTPSource)
HTTPSourceOption configures an HTTPSource.
func WithHTTPSourcesDir ¶ added in v0.0.10
func WithHTTPSourcesDir(dir string) HTTPSourceOption
WithHTTPSourcesDir configures the sources directory for the HTTP source.
type Modalities ¶
Modalities represents input/output modalities.
type Model ¶
type Model struct {
ID string `json:"id"`
Name string `json:"name"`
Attachment bool `json:"attachment"`
Reasoning bool `json:"reasoning"`
Temperature bool `json:"temperature"`
ToolCall bool `json:"tool_call"`
Knowledge *string `json:"knowledge,omitempty"`
ReleaseDate string `json:"release_date"`
LastUpdated string `json:"last_updated"`
Modalities Modalities `json:"modalities"`
OpenWeights bool `json:"open_weights"`
Cost *Cost `json:"cost,omitempty"`
Limit Limit `json:"limit"`
}
Model represents a model in models.dev.
type Provider ¶
type Provider struct {
ID string `json:"id"`
Env []string `json:"env"`
NPM string `json:"npm"`
API *string `json:"api,omitempty"`
Name string `json:"name"`
Doc string `json:"doc"`
Models map[string]Model `json:"models"`
}
Provider represents a provider in models.dev.