feat: add after_id pagination for chat messages (#24531)

This commit is contained in:
david-fraley
2026-04-28 08:31:33 -05:00
committed by GitHub
parent 8fe11e9b14
commit 5222db86c7
8 changed files with 511 additions and 13 deletions
+11 -1
View File
@@ -2571,7 +2571,14 @@ func (c *ExperimentalClient) GetChat(ctx context.Context, chatID uuid.UUID) (Cha
// GetChatMessages.
type ChatMessagesPaginationOptions struct {
BeforeID int64
Limit int
// AfterID, when > 0, restricts results to messages with id strictly
// greater than AfterID. When set without BeforeID, results come back
// in ASCENDING id order so a polling caller can advance its cursor
// to max(returned_ids) without gaps. When combined with BeforeID,
// results come back in DESC order over the open range
// (AfterID, BeforeID).
AfterID int64
Limit int
}
// GetChatMessages returns the messages and queued messages for a chat.
@@ -2583,6 +2590,9 @@ func (c *ExperimentalClient) GetChatMessages(ctx context.Context, chatID uuid.UU
if opts.BeforeID > 0 {
q.Set("before_id", strconv.FormatInt(opts.BeforeID, 10))
}
if opts.AfterID > 0 {
q.Set("after_id", strconv.FormatInt(opts.AfterID, 10))
}
if opts.Limit > 0 {
q.Set("limit", strconv.Itoa(opts.Limit))
}