nolint:revive // get-return: revive assumes get* must be a getter, but this is an HTTP handler.
(rw http.ResponseWriter, r *http.Request)
| 4591 | |
| 4592 | //nolint:revive // get-return: revive assumes get* must be a getter, but this is an HTTP handler. |
| 4593 | func (api *API) getChatSystemPrompt(rw http.ResponseWriter, r *http.Request) { |
| 4594 | ctx := r.Context() |
| 4595 | if !api.Authorize(r, policy.ActionUpdate, rbac.ResourceDeploymentConfig) { |
| 4596 | httpapi.ResourceNotFound(rw) |
| 4597 | return |
| 4598 | } |
| 4599 | config, err := api.Database.GetChatSystemPromptConfig(ctx) |
| 4600 | if err != nil { |
| 4601 | httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{ |
| 4602 | Message: "Internal error fetching chat system prompt configuration.", |
| 4603 | Detail: err.Error(), |
| 4604 | }) |
| 4605 | return |
| 4606 | } |
| 4607 | httpapi.Write(ctx, rw, http.StatusOK, codersdk.ChatSystemPromptResponse{ |
| 4608 | SystemPrompt: config.ChatSystemPrompt, |
| 4609 | IncludeDefaultSystemPrompt: config.IncludeDefaultSystemPrompt, |
| 4610 | DefaultSystemPrompt: chatd.DefaultSystemPrompt, |
| 4611 | }) |
| 4612 | } |
| 4613 | |
| 4614 | func (api *API) putChatSystemPrompt(rw http.ResponseWriter, r *http.Request) { |
| 4615 | ctx := r.Context() |
no test coverage detected