MCPcopy Index your code
hub / github.com/coder/coder / getChatAdvisorConfig

Method getChatAdvisorConfig

coderd/exp_chats.go:5299–5322  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

5297//
5298//nolint:revive // get-return: revive assumes get* must be a getter, but this is an HTTP handler.
5299func (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.
5325func (api *API) putChatAdvisorConfig(rw http.ResponseWriter, r *http.Request) {

Callers 2

GetChatAdvisorConfigMethod · 0.80
chatAdvisorConfigFunction · 0.80

Calls 5

WriteFunction · 0.92
ContextMethod · 0.65
GetChatAdvisorConfigMethod · 0.65
ErrorMethod · 0.45
UnmarshalMethod · 0.45

Tested by 1

GetChatAdvisorConfigMethod · 0.64