[GH-ISSUE #94] [Feature Request] Add a token cutoff #81

Closed
opened 2026-03-02 11:46:22 +03:00 by kerem · 11 comments
Owner

Originally created by @Reledia on GitHub (Apr 10, 2024).
Original GitHub issue: https://github.com/karakeep-app/karakeep/issues/94

Hello. Sometimes, some pages I save contains essays or stories that can span aboce 20k+ tokens. This does not only used much more credits/money when doing a request, but it consumes a lot of time (from 4s to >50s) and the prompt get lost in the way.

Would it be possible to add an env variable so we can set the max number of tokens to send in a single request?

Originally created by @Reledia on GitHub (Apr 10, 2024). Original GitHub issue: https://github.com/karakeep-app/karakeep/issues/94 Hello. Sometimes, some pages I save contains essays or stories that can span aboce 20k+ tokens. This does not only used much more credits/money when doing a request, but it consumes a lot of time (from 4s to >50s) and the prompt get lost in the way. Would it be possible to add an env variable so we can set the max number of tokens to send in a single request?
Author
Owner

@MohamedBassem commented on GitHub (Apr 11, 2024):

Hi, there's already a hardcoded token cutoff of 1500 tokens (to fit in the context window of some models). But making this configurable makes a ton of sense :) Should be easy to implement and include in the next release. Thanks for the suggestion!

<!-- gh-comment-id:2048956133 --> @MohamedBassem commented on GitHub (Apr 11, 2024): Hi, there's already a hardcoded token cutoff of 1500 tokens (to fit in the context window of some models). But making this configurable makes a ton of sense :) Should be easy to implement and include in the next release. Thanks for the suggestion!
Author
Owner

@Reledia commented on GitHub (Apr 11, 2024):

I'm happy to hear this was already implemented, but I observe a different thing in my logs

Screenshot_20240411_125943_Vivaldi.jpg

My version of hoarder should be the latest available

<!-- gh-comment-id:2049435793 --> @Reledia commented on GitHub (Apr 11, 2024): I'm happy to hear this was already implemented, but I observe a different thing in my logs ![Screenshot_20240411_125943_Vivaldi.jpg](https://github.com/MohamedBassem/hoarder-app/assets/82183718/92e1c732-39ec-4061-a27d-25b016f1ebf3) My version of hoarder should be the latest available
Author
Owner

@MohamedBassem commented on GitHub (Apr 11, 2024):

Oh wow, that's a lot of tokens. Hmmm, I have a guess. I'm currently approximating tokens to words. So technically speaking I'm truncating the content to 1500 words not tokens. Maybe that's where the difference is coming from? Do you have a link that you are willing to share for me to debug this? Thanks!

<!-- gh-comment-id:2049451946 --> @MohamedBassem commented on GitHub (Apr 11, 2024): Oh wow, that's a lot of tokens. Hmmm, I have a guess. I'm currently approximating `tokens` to `words`. So technically speaking I'm truncating the content to 1500 words not tokens. Maybe that's where the difference is coming from? Do you have a link that you are willing to share for me to debug this? Thanks!
Author
Owner

@Reledia commented on GitHub (Apr 11, 2024):

I don't wanna share the actual link because it's very explicit, but it was a chapter of a fanfiction from AO3, so very heavy on words

<!-- gh-comment-id:2049457369 --> @Reledia commented on GitHub (Apr 11, 2024): I don't wanna share the actual link because it's very explicit, but it was a chapter of a fanfiction from AO3, so very heavy on words
Author
Owner

@MohamedBassem commented on GitHub (Apr 15, 2024):

Turned out, I had a bug in the content truncating logic. Sending a fix now.

<!-- gh-comment-id:2057871678 --> @MohamedBassem commented on GitHub (Apr 15, 2024): Turned out, I had a bug in the content truncating logic. Sending a fix now.
Author
Owner

@Reledia commented on GitHub (Apr 15, 2024):

By looking at the commit, was the truncate function sending words only after the 1500th one?

<!-- gh-comment-id:2057922199 --> @Reledia commented on GitHub (Apr 15, 2024): By looking at the commit, was the truncate function sending words only after the 1500th one?
Author
Owner

@MohamedBassem commented on GitHub (Apr 15, 2024):

Yeah, noob mistake :)

<!-- gh-comment-id:2057923496 --> @MohamedBassem commented on GitHub (Apr 15, 2024): Yeah, noob mistake :)
Author
Owner

@Reledia commented on GitHub (Apr 15, 2024):

Dont worry, it happens to everyone :)
But maybe in the next release it would be better to inform users to re-process all previous bookmarks?

<!-- gh-comment-id:2057924952 --> @Reledia commented on GitHub (Apr 15, 2024): Dont worry, it happens to everyone :) But maybe in the next release it would be better to inform users to re-process all previous bookmarks?
Author
Owner

@MohamedBassem commented on GitHub (Apr 15, 2024):

The bug only affects bookmarks with content larger than 1500 though, so it's not all bad. I'll mention it in the release note and let people decide whether they want to re-process or not (given that re-processing can be expensive for those using openai for example).

<!-- gh-comment-id:2057928393 --> @MohamedBassem commented on GitHub (Apr 15, 2024): The bug only affects bookmarks with content larger than 1500 though, so it's not all bad. I'll mention it in the release note and let people decide whether they want to re-process or not (given that re-processing can be expensive for those using openai for example).
Author
Owner

@Reledia commented on GitHub (Apr 15, 2024):

Seems like the best solution. Thanks for the time

<!-- gh-comment-id:2057929409 --> @Reledia commented on GitHub (Apr 15, 2024): Seems like the best solution. Thanks for the time
Author
Owner

@MohamedBassem commented on GitHub (Apr 15, 2024):

Hotfix 0.12.1 released with the fix. Thanks for the report!

<!-- gh-comment-id:2057961161 --> @MohamedBassem commented on GitHub (Apr 15, 2024): Hotfix `0.12.1` released with the fix. Thanks for the report!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/karakeep#81
No description provided.