mirror of
https://github.com/langgenius/dify-plugins.git
synced 2026-07-22 01:55:36 -04:00
[Plugin Request]: Tokenizer #56
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @DavideDelbianco on GitHub (May 30, 2025).
Plugin Name
Tokenizer
Function Description
The plugin should allow the selection of tokenization method (GPT, Tiktoken, etc..)
It should expose the ability to tokenize a text and/or return the number of tokens
It would allow to evaluate a received text to reject a query before sending it to LLM node
It would allow to create a workflow tool to put together with the use of Storage plugins a workflow tool that can count the number of used tokens by userid / appid / whatever.
Most of the code is probably already in the Dify repo because a similar functionality has been added as an ENV variable option.
It would be a nice alternative waiting for the team to expose as an output the LLM usage info from the LLM node
Official Website URL
No response
@jingfelix commented on GitHub (Jun 23, 2025):
https://github.com/jingfelix/dify-plugin-tokenizer
Hi, I've built a tokenizer plugin using transformers.AutoTokenizer. Does that meet your requirements? I'll add more details and get it listed later today.
Due to the limitation of cloud.dify.ai, you can only deploy it to your local environment (for now)
@DavideDelbianco commented on GitHub (Jun 27, 2025):
This will probably help me a lot.
I would like to fork it to allow choosing either Transformers or TikToken because the latter is specialized in OpenAI models and is a lot faster
@jingfelix commented on GitHub (Jun 27, 2025):
I considered using
tiktokendirectly, but it only supports OpenAI models, so I chosetransformersto make it more versatile. I will consider addingtiktokensupport in the future, although this may not be a priority.If you have any updates or other needs on this issue, please feel free to contact me.