| 28 | } |
| 29 | |
| 30 | func applyCodexWireAPI(path, endpointName, model string) error { |
| 31 | data, err := readConfigFile(path, "toml") |
| 32 | if err != nil { |
| 33 | return err |
| 34 | } |
| 35 | keyPath := "model_providers." + quoteSegmentIfNeeded(endpointName) + ".wire_api" |
| 36 | parts, err := editorconfig.Parse(keyPath) |
| 37 | if err != nil { |
| 38 | return err |
| 39 | } |
| 40 | if strings.HasPrefix(model, "gpt") { |
| 41 | editorconfig.Set(data, parts, "responses") |
| 42 | } else { |
| 43 | editorconfig.Unset(data, parts) |
| 44 | } |
| 45 | return writeConfigFile(path, "toml", data) |
| 46 | } |
| 47 | |
| 48 | // quoteSegmentIfNeeded wraps name in TOML quotes when it would not be a |
| 49 | // bare key (e.g. contains a hyphen or slash). |