| 1 | //go:build ignore |
| 2 | |
| 3 | // Run from the repository root: go run scripts/generate-provider-catalog.go |
| 4 | package main |
| 5 | |
| 6 | import ( |
| 7 | "encoding/json" |
| 8 | "os" |
| 9 | "reasonix/internal/config" |
| 10 | ) |
| 11 | |
| 12 | func main() { |
| 13 | catalogs := map[string]config.ProviderCatalog{} |
| 14 | templates := []map[string]any{} |
| 15 | extended := map[string]bool{"doubao-chat": true, "doubao-responses": true, "baidu-cloud": true, "ppio": true, "qiniu": true, "xai-chat": true, "xai-responses": true, "cerebras": true, "together": true, "fireworks-chat": true, "fireworks-anthropic": true, "fireworks-responses": true, "amd-gpu-cloud": true, "deepseek-chat": true, "openai-responses": true, "openai-chat": true, "anthropic": true, "gemini": true, "siliconflow": true, "openrouter": true, "groq": true, "mistral": true, "ollama-local": true, "lmstudio": true} |
| 16 | for _, p := range config.CuratedProviderPresets() { |
| 17 | catalogs[p.ID] = config.CatalogForProviderPreset(p) |
| 18 | if !extended[p.ID] { |
| 19 | continue |
| 20 | } |
| 21 | e := p.Entries[0] |
| 22 | templates = append(templates, map[string]any{"id": p.ID, "label": p.Label, "description": p.Description, "keyEnv": p.KeyEnv, "provider": map[string]any{"name": e.Name, "kind": e.Kind, "baseUrl": e.BaseURL, "models": e.Models, "default": e.Default, "apiKeyEnv": e.APIKeyEnv, "webSearch": false}}) |
| 23 | } |
| 24 | data, err := json.MarshalIndent(map[string]any{"catalogs": catalogs, "templates": templates}, "", " ") |
| 25 | if err != nil { |
| 26 | panic(err) |
| 27 | } |
| 28 | if err := os.WriteFile("desktop/frontend/src/lib/providerCatalog.generated.json", append(data, '\n'), 0644); err != nil { |
| 29 | panic(err) |
| 30 | } |
| 31 | } |
| 32 |