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

Method ListChats

codersdk/chats.go:2047–2078  ·  view source on GitHub ↗

ListChats returns all chats for the authenticated user.

(ctx context.Context, opts *ListChatsOptions)

Source from the content-addressed store, hash-verified

2045
2046// ListChats returns all chats for the authenticated user.
2047func (c *ExperimentalClient) ListChats(ctx context.Context, opts *ListChatsOptions) ([]Chat, error) {
2048 var reqOpts []RequestOption
2049 if opts != nil {
2050 reqOpts = append(reqOpts, opts.Pagination.asRequestOption())
2051 if opts.Query != "" {
2052 reqOpts = append(reqOpts, func(r *http.Request) {
2053 q := r.URL.Query()
2054 q.Set("q", opts.Query)
2055 r.URL.RawQuery = q.Encode()
2056 })
2057 }
2058 if len(opts.Labels) > 0 {
2059 reqOpts = append(reqOpts, func(r *http.Request) {
2060 q := r.URL.Query()
2061 for k, v := range opts.Labels {
2062 q.Add("label", k+":"+v)
2063 }
2064 r.URL.RawQuery = q.Encode()
2065 })
2066 }
2067 }
2068 res, err := c.Request(ctx, http.MethodGet, "/api/experimental/chats", nil, reqOpts...)
2069 if err != nil {
2070 return nil, err
2071 }
2072 defer res.Body.Close()
2073 if res.StatusCode != http.StatusOK {
2074 return nil, ReadBodyAsError(res)
2075 }
2076 var chats []Chat
2077 return chats, json.NewDecoder(res.Body).Decode(&chats)
2078}
2079
2080// ListChatModels returns the available chat model catalog.
2081func (c *ExperimentalClient) ListChatModels(ctx context.Context) (ChatModelsResponse, error) {

Callers 7

TestListChatsFunction · 0.95
TestChatSharingDisabledFunction · 0.95
TestArchiveChatFunction · 0.80
TestUnarchiveChatFunction · 0.80

Calls 7

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

Tested by 7

TestListChatsFunction · 0.76
TestChatSharingDisabledFunction · 0.76
TestArchiveChatFunction · 0.64
TestUnarchiveChatFunction · 0.64