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)
| 5777 | // |
| 5778 | //nolint:revive // get-return: revive assumes get* must be a getter, but this is an HTTP handler. |
| 5779 | func (api *API) getUserChatCustomPrompt(rw http.ResponseWriter, r *http.Request) { |
| 5780 | var ( |
| 5781 | ctx = r.Context() |
| 5782 | apiKey = httpmw.APIKey(r) |
| 5783 | ) |
| 5784 | |
| 5785 | customPrompt, err := api.Database.GetUserChatCustomPrompt(ctx, apiKey.UserID) |
| 5786 | if err != nil { |
| 5787 | if !errors.Is(err, sql.ErrNoRows) { |
| 5788 | httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{ |
| 5789 | Message: "Error reading user chat custom prompt.", |
| 5790 | Detail: err.Error(), |
| 5791 | }) |
| 5792 | return |
| 5793 | } |
| 5794 | |
| 5795 | customPrompt = "" |
| 5796 | } |
| 5797 | |
| 5798 | httpapi.Write(ctx, rw, http.StatusOK, codersdk.UserChatCustomPrompt{ |
| 5799 | CustomPrompt: customPrompt, |
| 5800 | }) |
| 5801 | } |
| 5802 | |
| 5803 | // EXPERIMENTAL: this endpoint is experimental and is subject to change. |
| 5804 | func (api *API) putUserChatCustomPrompt(rw http.ResponseWriter, r *http.Request) { |