Removed .env and .env.backup from git tracking and consolidated configuration into .env.example. Updated .gitignore to robustly prevent accidental inclusion of sensitive files.
59 lines
1.4 KiB
Go
59 lines
1.4 KiB
Go
package models
|
|
|
|
type ModelRegistry struct {
|
|
Providers map[string]ProviderInfo `json:"-"`
|
|
}
|
|
|
|
type ProviderInfo struct {
|
|
ID string `json:"id"`
|
|
Name string `json:"name"`
|
|
Models map[string]ModelMetadata `json:"models"`
|
|
}
|
|
|
|
type ModelMetadata struct {
|
|
ID string `json:"id"`
|
|
Name string `json:"name"`
|
|
Cost *ModelCost `json:"cost,omitempty"`
|
|
Limit *ModelLimit `json:"limit,omitempty"`
|
|
Modalities *ModelModalities `json:"modalities,omitempty"`
|
|
ToolCall *bool `json:"tool_call,omitempty"`
|
|
Reasoning *bool `json:"reasoning,omitempty"`
|
|
}
|
|
|
|
type ModelCost struct {
|
|
Input float64 `json:"input"`
|
|
Output float64 `json:"output"`
|
|
CacheRead *float64 `json:"cache_read,omitempty"`
|
|
CacheWrite *float64 `json:"cache_write,omitempty"`
|
|
}
|
|
|
|
type ModelLimit struct {
|
|
Context uint32 `json:"context"`
|
|
Output uint32 `json:"output"`
|
|
}
|
|
|
|
type ModelModalities struct {
|
|
Input []string `json:"input"`
|
|
Output []string `json:"output"`
|
|
}
|
|
|
|
func (r *ModelRegistry) FindModel(modelID string) *ModelMetadata {
|
|
// First try exact match in models map
|
|
for _, provider := range r.Providers {
|
|
if model, ok := provider.Models[modelID]; ok {
|
|
return &model
|
|
}
|
|
}
|
|
|
|
// Try searching by ID in metadata
|
|
for _, provider := range r.Providers {
|
|
for _, model := range provider.Models {
|
|
if model.ID == modelID {
|
|
return &model
|
|
}
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|