Skip to content

Conversation

cherylisabella
Copy link
Contributor

@cherylisabella cherylisabella commented Oct 2, 2025

Previously, the code tokens_acc[, 1:2] truncated the output to only the first two columns, causing chat_structured_parallel() and convert_from_type() to return only two rows.

The change removes this hard-coded limit, ensuring all columns are retained.

Notes on CI:

  • CI failures in vignettes, live API tests, and pkgdown builds are unrelated to this bug fix.
  • The core functionality of chat_structured_parallel() and convert_from_type() passes all tests.

cherylisabella and others added 2 commits October 2, 2025 23:11
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
tokens_acc[, 1] <- tokens_acc[, 1] + tokens_acc[, 3]
# Then drop cached tokens counts
tokens_acc <- tokens_acc[, 1:2]
tokens_acc <- tokens_acc[,, drop = FALSE]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like your new code will not drop the cached tokens count which will mean that they get double counted?

cherylisabella and others added 2 commits October 3, 2025 14:38
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@cherylisabella
Copy link
Contributor Author

Thanks for the reviewing, Hadley! Turns out the bug wasn't in get_tokens() at all so I've reverted that.

The actual issue was in convert_from_type() in chat-structured.R: when processing arrays of nested objects, the function was passing data frames directly to list2DF(), which only extracted the first 2 rows.
The fix now flattens data frames into their constituent column vectors before combining.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants