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

Method GetChatPrompts

codersdk/chats.go:3143–3162  ·  view source on GitHub ↗

GetChatPrompts returns the user prompts for a chat in newest-first order. It is a thin endpoint dedicated to the composer's prompt history cycle: only user-visible user messages are included, and only their text parts (concatenated in the original order) are returned. Whitespace-only prompts are fil

(ctx context.Context, chatID uuid.UUID, opts *ChatPromptsOptions)

Source from the content-addressed store, hash-verified

3141// returned. Whitespace-only prompts are filtered server-side so the
3142// caller never has to skip blank entries while cycling.
3143func (c *ExperimentalClient) GetChatPrompts(ctx context.Context, chatID uuid.UUID, opts *ChatPromptsOptions) (ChatPromptsResponse, error) {
3144 reqOpts := []RequestOption{}
3145 if opts != nil && opts.Limit > 0 {
3146 reqOpts = append(reqOpts, func(r *http.Request) {
3147 q := r.URL.Query()
3148 q.Set("limit", strconv.Itoa(opts.Limit))
3149 r.URL.RawQuery = q.Encode()
3150 })
3151 }
3152 res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/experimental/chats/%s/prompts", chatID), nil, reqOpts...)
3153 if err != nil {
3154 return ChatPromptsResponse{}, err
3155 }
3156 defer res.Body.Close()
3157 if res.StatusCode != http.StatusOK {
3158 return ChatPromptsResponse{}, ReadBodyAsError(res)
3159 }
3160 var resp ChatPromptsResponse
3161 return resp, json.NewDecoder(res.Body).Decode(&resp)
3162}
3163
3164// UpdateChat patches a chat resource.
3165func (c *ExperimentalClient) UpdateChat(ctx context.Context, chatID uuid.UUID, req UpdateChatRequest) error {

Callers 1

TestGetChatUserPromptsFunction · 0.95

Calls 5

ReadBodyAsErrorFunction · 0.85
EncodeMethod · 0.80
SetMethod · 0.65
CloseMethod · 0.65
RequestMethod · 0.45

Tested by 1

TestGetChatUserPromptsFunction · 0.76