1 line
4.9 KiB
JSON
1 line
4.9 KiB
JSON
{"repo": "78188869/agent-infra", "files": {"internal/seed/providers.go": {"3d0bb8c6d6ad17d2145bcd1930f4bb547453bc86": {"t": 1785746084.9320905, "n": 2146, "h": "a14399e3655365ba", "c": "// Package seed provides database seeding functionality.\npackage seed\n\nimport (\n\t\"context\"\n\t\"log\"\n\n\t\"github.com/example/agent-infra/internal/model\"\n\t\"gorm.io/datatypes\"\n\t\"gorm.io/gorm\"\n)\n\n// SystemProviders defines the system preset providers.\nvar SystemProviders = []model.Provider{\n\t{\n\t\tScope: model.ProviderScopeSystem,\n\t\tName: \"claude-code\",\n\t\tType: model.ProviderTypeClaudeCode,\n\t\tDescription: \"Official Claude Code CLI from Anthropic\",\n\t\tAPIEndpoint: \"https://api.anthropic.com\",\n\t\tRuntimeType: model.RuntimeTypeCLI,\n\t\tStatus: model.ProviderStatusActive,\n\t},\n\t{\n\t\tScope: model.ProviderScopeSystem,\n\t\tName: \"zhipu-glm\",\n\t\tType: model.ProviderTypeAnthropicCompat,\n\t\tDescription: \"Zhipu GLM via Anthropic compatible API\",\n\t\tAPIEndpoint: \"https://open.bigmodel.cn/api/anthropic\",\n\t\tAPIKeyRef: \"zhipu-api-key\",\n\t\tModelMapping: datatypes.JSON(`{\"default\":\"glm-5\",\"opus\":\"glm-5\",\"sonnet\":\"glm-4.7\",\"haiku\":\"glm-4.5-air\"}`),\n\t\tRuntimeType: model.RuntimeTypeCLI,\n\t\tStatus: model.ProviderStatusActive,\n\t},\n\t{\n\t\tScope: model.ProviderScopeSystem,\n\t\tName: \"deepseek\",\n\t\tType: model.ProviderTypeAnthropicCompat,\n\t\tDescription: \"DeepSeek via Anthropic compatible API\",\n\t\tAPIEndpoint: \"https://api.deepseek.com\",\n\t\tAPIKeyRef: \"deepseek-api-key\",\n\t\tModelMapping: datatypes.JSON(`{\"default\":\"deepseek-chat\",\"opus\":\"deepseek-reasoner\",\"sonnet\":\"deepseek-chat\",\"haiku\":\"deepseek-chat\"}`),\n\t\tRuntimeType: model.RuntimeTypeCLI,\n\t\tStatus: model.ProviderStatusActive,\n\t},\n}\n\n// SeedProviders initializes system providers if they don't exist.\nfunc SeedProviders(db *gorm.DB) error {\n\tctx := context.Background()\n\n\tfor _, provider := range SystemProviders {\n\t\tvar existing model.Provider\n\t\terr := db.WithContext(ctx).\n\t\t\tWhere(\"scope = ? AND name = ?\", model.ProviderScopeSystem, provider.Name).\n\t\t\tFirst(&existing).Error\n\n\t\tif err == gorm.ErrRecordNotFound {\n\t\t\tif err := db.WithContext(ctx).Create(&provider).Error; err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tlog.Printf(\"Seeded provider: %s\", provider.Name)\n\t\t} else if err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}\n"}, "38281d7f71f03a546a2c1add5afa5eba358d5325": {"t": 1785759754.126901, "n": 2146, "h": "a14399e3655365ba", "c": "// Package seed provides database seeding functionality.\npackage seed\n\nimport (\n\t\"context\"\n\t\"log\"\n\n\t\"github.com/example/agent-infra/internal/model\"\n\t\"gorm.io/datatypes\"\n\t\"gorm.io/gorm\"\n)\n\n// SystemProviders defines the system preset providers.\nvar SystemProviders = []model.Provider{\n\t{\n\t\tScope: model.ProviderScopeSystem,\n\t\tName: \"claude-code\",\n\t\tType: model.ProviderTypeClaudeCode,\n\t\tDescription: \"Official Claude Code CLI from Anthropic\",\n\t\tAPIEndpoint: \"https://api.anthropic.com\",\n\t\tRuntimeType: model.RuntimeTypeCLI,\n\t\tStatus: model.ProviderStatusActive,\n\t},\n\t{\n\t\tScope: model.ProviderScopeSystem,\n\t\tName: \"zhipu-glm\",\n\t\tType: model.ProviderTypeAnthropicCompat,\n\t\tDescription: \"Zhipu GLM via Anthropic compatible API\",\n\t\tAPIEndpoint: \"https://open.bigmodel.cn/api/anthropic\",\n\t\tAPIKeyRef: \"zhipu-api-key\",\n\t\tModelMapping: datatypes.JSON(`{\"default\":\"glm-5\",\"opus\":\"glm-5\",\"sonnet\":\"glm-4.7\",\"haiku\":\"glm-4.5-air\"}`),\n\t\tRuntimeType: model.RuntimeTypeCLI,\n\t\tStatus: model.ProviderStatusActive,\n\t},\n\t{\n\t\tScope: model.ProviderScopeSystem,\n\t\tName: \"deepseek\",\n\t\tType: model.ProviderTypeAnthropicCompat,\n\t\tDescription: \"DeepSeek via Anthropic compatible API\",\n\t\tAPIEndpoint: \"https://api.deepseek.com\",\n\t\tAPIKeyRef: \"deepseek-api-key\",\n\t\tModelMapping: datatypes.JSON(`{\"default\":\"deepseek-chat\",\"opus\":\"deepseek-reasoner\",\"sonnet\":\"deepseek-chat\",\"haiku\":\"deepseek-chat\"}`),\n\t\tRuntimeType: model.RuntimeTypeCLI,\n\t\tStatus: model.ProviderStatusActive,\n\t},\n}\n\n// SeedProviders initializes system providers if they don't exist.\nfunc SeedProviders(db *gorm.DB) error {\n\tctx := context.Background()\n\n\tfor _, provider := range SystemProviders {\n\t\tvar existing model.Provider\n\t\terr := db.WithContext(ctx).\n\t\t\tWhere(\"scope = ? AND name = ?\", model.ProviderScopeSystem, provider.Name).\n\t\t\tFirst(&existing).Error\n\n\t\tif err == gorm.ErrRecordNotFound {\n\t\t\tif err := db.WithContext(ctx).Create(&provider).Error; err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tlog.Printf(\"Seeded provider: %s\", provider.Name)\n\t\t} else if err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}\n"}}}} |