()
| 38 | } |
| 39 | |
| 40 | func main() { |
| 41 | schema := Schema{ |
| 42 | Providers: make(map[string]FieldGroup), |
| 43 | ProviderAliases: map[string]string{ |
| 44 | "azure": "openai", |
| 45 | "bedrock": "anthropic", |
| 46 | }, |
| 47 | } |
| 48 | |
| 49 | // General options from ChatModelCallConfig, excluding |
| 50 | // the provider_options field which is handled separately. |
| 51 | schema.General = extractFields( |
| 52 | reflect.TypeOf(codersdk.ChatModelCallConfig{}), |
| 53 | "", |
| 54 | map[string]bool{"ProviderOptions": true}, |
| 55 | ) |
| 56 | |
| 57 | // Provider-specific options. Each entry maps a provider key |
| 58 | // to the concrete options struct used for that provider. |
| 59 | providerTypes := []struct { |
| 60 | key string |
| 61 | typ reflect.Type |
| 62 | }{ |
| 63 | {"openai", reflect.TypeOf(codersdk.ChatModelOpenAIProviderOptions{})}, |
| 64 | {"anthropic", reflect.TypeOf(codersdk.ChatModelAnthropicProviderOptions{})}, |
| 65 | {"google", reflect.TypeOf(codersdk.ChatModelGoogleProviderOptions{})}, |
| 66 | {"openaicompat", reflect.TypeOf(codersdk.ChatModelOpenAICompatProviderOptions{})}, |
| 67 | {"openrouter", reflect.TypeOf(codersdk.ChatModelOpenRouterProviderOptions{})}, |
| 68 | {"vercel", reflect.TypeOf(codersdk.ChatModelVercelProviderOptions{})}, |
| 69 | } |
| 70 | |
| 71 | for _, p := range providerTypes { |
| 72 | schema.Providers[p.key] = extractFields(p.typ, "", nil) |
| 73 | } |
| 74 | |
| 75 | out, err := json.MarshalIndent(schema, "", "\t") |
| 76 | if err != nil { |
| 77 | _, _ = fmt.Fprintf(os.Stderr, "marshal schema: %v\n", err) |
| 78 | os.Exit(1) |
| 79 | } |
| 80 | |
| 81 | // Print the generated header and JSON body. |
| 82 | _, _ = fmt.Println("// Code generated by scripts/modeloptionsgen. DO NOT EDIT.") |
| 83 | _, _ = fmt.Println(string(out)) |
| 84 | } |
| 85 | |
| 86 | // extractFields walks the struct fields of t and returns a FieldGroup. |
| 87 | // prefix is used to build dot-separated json_name values for nested |
nothing calls this directly
no test coverage detected