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)
| 3141 | // returned. Whitespace-only prompts are filtered server-side so the |
| 3142 | // caller never has to skip blank entries while cycling. |
| 3143 | func (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. |
| 3165 | func (c *ExperimentalClient) UpdateChat(ctx context.Context, chatID uuid.UUID, req UpdateChatRequest) error { |