EXPERIMENTAL: this endpoint is experimental and is subject to change.
(rw http.ResponseWriter, r *http.Request)
| 5127 | |
| 5128 | // EXPERIMENTAL: this endpoint is experimental and is subject to change. |
| 5129 | func (api *API) putChatComputerUseProvider(rw http.ResponseWriter, r *http.Request) { |
| 5130 | ctx := r.Context() |
| 5131 | if !api.Authorize(r, policy.ActionUpdate, rbac.ResourceDeploymentConfig) { |
| 5132 | httpapi.Forbidden(rw) |
| 5133 | return |
| 5134 | } |
| 5135 | |
| 5136 | var req codersdk.UpdateChatComputerUseProviderRequest |
| 5137 | if !httpapi.Read(ctx, rw, r, &req) { |
| 5138 | return |
| 5139 | } |
| 5140 | if !chattool.IsSupportedComputerUseProvider(req.Provider) { |
| 5141 | httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{ |
| 5142 | Message: "Invalid computer use provider.", |
| 5143 | Detail: fmt.Sprintf( |
| 5144 | "Expected one of: %s. Got %q.", |
| 5145 | strings.Join(chattool.SupportedComputerUseProviders(), ", "), |
| 5146 | req.Provider, |
| 5147 | ), |
| 5148 | }) |
| 5149 | return |
| 5150 | } |
| 5151 | |
| 5152 | if err := api.Database.UpsertChatComputerUseProvider(ctx, req.Provider); err != nil { |
| 5153 | httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{ |
| 5154 | Message: "Internal error updating computer use provider.", |
| 5155 | Detail: err.Error(), |
| 5156 | }) |
| 5157 | return |
| 5158 | } |
| 5159 | rw.WriteHeader(http.StatusNoContent) |
| 5160 | } |
| 5161 | |
| 5162 | func (api *API) deploymentChatDebugLoggingEnabled() bool { |
| 5163 | return api.DeploymentValues != nil && api.DeploymentValues.AI.Chat.DebugLoggingEnabled.Value() |
nothing calls this directly
no test coverage detected