mirror of
https://github.com/langgenius/dify-plugin-sdks.git
synced 2026-07-22 02:15:22 -04:00
[Offline Deployment] Token Count Calculation Failure Due to GPT-2 Dependency #20
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 @toddlerya on GitHub (Mar 20, 2025).
Bug Description
When deploying in an offline environment using docker-compose, an error occurs in token count calculation. The local model service does not provide token length calculation capabilities, so the system falls back to the
_get_num_tokens_by_gpt2()method. However, in the offline environment, accessing theopenaipublic.blob.core.windows.netservice fails, resulting in network request errors .Temporary Workaround
Modify the
get_llm_num_tokens()andget_text_embedding_num_tokens()functions in dify_plugin/core_plugin_executor.py to directly use thelen()method to calculate num_tokens and return the result.Expectation
Provide an offline-friendly method for calculating token lengths without relying on GPT-2, enabling fully self-contained offline deployment .