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

Method GetChatMessages

codersdk/chats.go:3100–3127  ·  view source on GitHub ↗

GetChatMessages returns the messages and queued messages for a chat.

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

Source from the content-addressed store, hash-verified

3098
3099// GetChatMessages returns the messages and queued messages for a chat.
3100func (c *ExperimentalClient) GetChatMessages(ctx context.Context, chatID uuid.UUID, opts *ChatMessagesPaginationOptions) (ChatMessagesResponse, error) {
3101 reqOpts := []RequestOption{}
3102 if opts != nil {
3103 reqOpts = append(reqOpts, func(r *http.Request) {
3104 q := r.URL.Query()
3105 if opts.BeforeID > 0 {
3106 q.Set("before_id", strconv.FormatInt(opts.BeforeID, 10))
3107 }
3108 if opts.AfterID > 0 {
3109 q.Set("after_id", strconv.FormatInt(opts.AfterID, 10))
3110 }
3111 if opts.Limit > 0 {
3112 q.Set("limit", strconv.Itoa(opts.Limit))
3113 }
3114 r.URL.RawQuery = q.Encode()
3115 })
3116 }
3117 res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/experimental/chats/%s/messages", chatID), nil, reqOpts...)
3118 if err != nil {
3119 return ChatMessagesResponse{}, err
3120 }
3121 defer res.Body.Close()
3122 if res.StatusCode != http.StatusOK {
3123 return ChatMessagesResponse{}, ReadBodyAsError(res)
3124 }
3125 var resp ChatMessagesResponse
3126 return resp, json.NewDecoder(res.Body).Decode(&resp)
3127}
3128
3129// ChatPromptsOptions are optional query parameters for GetChatPrompts.
3130type ChatPromptsOptions struct {

Calls 5

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