[PR #3286] [CLOSED] add token estimation to token counting for truncation #4260

Closed
opened 2026-02-22 18:35:28 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Mintplex-Labs/anything-llm/pull/3286
Author: @timothycarambat
Created: 2/19/2025
Status: Closed

Base: masterHead: 3280-token-counting-server-side-truncation-improvements


📝 Commits (2)

  • f5186b8 add token estimation to token counting for truncation
  • 357bf04 wip

📊 Changes

2 files changed (+39 additions, -74 deletions)

View changed files

📝 server/utils/helpers/chat/index.js (+31 -73)
📝 server/utils/helpers/tiktoken.js (+8 -1)

📄 Description

Pull Request Type

  • feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 🔨 chore
  • 📝 docs

Relevant Issues

resolves #3280

What is in this change?

  • Removes cannonball truncation in favor of end-truncation methods
  • Simplifies counting and tokenization of very large inputs by token estimate to bypass performance issues on low-end devices.

Additional Information

Developer Validations

  • I ran yarn lint from the root of the repo & committed changes
  • Relevant documentation has been updated
  • I have tested my code functionality
  • Docker build succeeds locally

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Mintplex-Labs/anything-llm/pull/3286 **Author:** [@timothycarambat](https://github.com/timothycarambat) **Created:** 2/19/2025 **Status:** ❌ Closed **Base:** `master` ← **Head:** `3280-token-counting-server-side-truncation-improvements` --- ### 📝 Commits (2) - [`f5186b8`](https://github.com/Mintplex-Labs/anything-llm/commit/f5186b8eb9856694f81ac17549288febff2fb8ac) add token estimation to token counting for truncation - [`357bf04`](https://github.com/Mintplex-Labs/anything-llm/commit/357bf04c19d8bd73a0357b6e2732ee7eab7f5291) wip ### 📊 Changes **2 files changed** (+39 additions, -74 deletions) <details> <summary>View changed files</summary> 📝 `server/utils/helpers/chat/index.js` (+31 -73) 📝 `server/utils/helpers/tiktoken.js` (+8 -1) </details> ### 📄 Description ### Pull Request Type <!-- For change type, change [ ] to [x]. --> - [ ] ✨ feat - [ ] 🐛 fix - [ ] ♻️ refactor - [ ] 💄 style - [ ] 🔨 chore - [ ] 📝 docs ### Relevant Issues <!-- Use "resolves #xxx" to auto resolve on merge. Otherwise, please use "connect #xxx" --> resolves #3280 ### What is in this change? - Removes cannonball truncation in favor of end-truncation methods - Simplifies counting and tokenization of very large inputs by token estimate to bypass performance issues on low-end devices. <!-- Describe the changes in this PR that are impactful to the repo. --> ### Additional Information <!-- Add any other context about the Pull Request here that was not captured above. --> ### Developer Validations <!-- All of the applicable items should be checked. --> - [ ] I ran `yarn lint` from the root of the repo & committed changes - [ ] Relevant documentation has been updated - [ ] I have tested my code functionality - [ ] Docker build succeeds locally --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-22 18:35:28 -05:00
yindo changed title from [PR #3286] add token estimation to token counting for truncation to [PR #3286] [CLOSED] add token estimation to token counting for truncation 2026-06-05 15:17:38 -04:00
yindo closed this issue 2026-06-05 15:17:39 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#4260