EXPERIMENTAL: this endpoint is experimental and is subject to change. nolint:revive // get-return: revive assumes get* must be a getter, but this is an HTTP handler.
(rw http.ResponseWriter, r *http.Request)
| 5297 | // |
| 5298 | //nolint:revive // get-return: revive assumes get* must be a getter, but this is an HTTP handler. |
| 5299 | func (api *API) getChatAdvisorConfig(rw http.ResponseWriter, r *http.Request) { |
| 5300 | ctx := r.Context() |
| 5301 | raw, err := api.Database.GetChatAdvisorConfig(ctx) |
| 5302 | if err != nil { |
| 5303 | httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{ |
| 5304 | Message: "Internal error fetching advisor configuration.", |
| 5305 | Detail: err.Error(), |
| 5306 | }) |
| 5307 | return |
| 5308 | } |
| 5309 | |
| 5310 | var resp codersdk.AdvisorConfig |
| 5311 | if err := json.Unmarshal([]byte(raw), &resp); err != nil { |
| 5312 | httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{ |
| 5313 | Message: "Stored advisor configuration is invalid.", |
| 5314 | Detail: err.Error(), |
| 5315 | }) |
| 5316 | return |
| 5317 | } |
| 5318 | resp.MaxUsesPerRun = max(resp.MaxUsesPerRun, 0) |
| 5319 | resp.MaxOutputTokens = max(resp.MaxOutputTokens, 0) |
| 5320 | |
| 5321 | httpapi.Write(ctx, rw, http.StatusOK, resp) |
| 5322 | } |
| 5323 | |
| 5324 | // EXPERIMENTAL: this endpoint is experimental and is subject to change. |
| 5325 | func (api *API) putChatAdvisorConfig(rw http.ResponseWriter, r *http.Request) { |