mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-08 22:21:35 +00:00
fixes: expose flag to disable token counter (#11344)
* fixes: expose flag to disable token counter * fix add disable_token_counter
This commit is contained in:
parent
3db272b6d2
commit
a73cf185ac
4 changed files with 22 additions and 3 deletions
|
|
@ -217,6 +217,7 @@ use_client: bool = False
|
|||
ssl_verify: Union[str, bool] = True
|
||||
ssl_certificate: Optional[str] = None
|
||||
disable_streaming_logging: bool = False
|
||||
disable_token_counter: bool = False
|
||||
disable_add_transform_inline_image_block: bool = False
|
||||
in_memory_llm_clients_cache: LLMClientCache = LLMClientCache()
|
||||
safe_memory_mode: bool = False
|
||||
|
|
|
|||
|
|
@ -362,6 +362,15 @@ def token_counter(
|
|||
"""
|
||||
from litellm.utils import convert_list_message_to_dict
|
||||
|
||||
#########################################################
|
||||
# Flag to disable token counter
|
||||
# We've gotten reports of this consuming CPU cycles,
|
||||
# exposing this flag to allow users to disable
|
||||
# it to confirm if this is indeed the issue
|
||||
#########################################################
|
||||
if litellm.disable_token_counter is True:
|
||||
return 0
|
||||
|
||||
verbose_logger.debug(
|
||||
f"messages in token_counter: {messages}, text in token_counter: {text}"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,5 @@ model_list:
|
|||
model: openai/*
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
litellm_settings:
|
||||
disable_token_counter: True
|
||||
|
|
|
|||
|
|
@ -1697,6 +1697,16 @@ def token_counter(
|
|||
|
||||
Kept for backwards compatibility.
|
||||
"""
|
||||
|
||||
#########################################################
|
||||
# Flag to disable token counter
|
||||
# We've gotten reports of this consuming CPU cycles,
|
||||
# exposing this flag to allow users to disable
|
||||
# it to confirm if this is indeed the issue
|
||||
#########################################################
|
||||
if litellm.disable_token_counter is True:
|
||||
return 0
|
||||
|
||||
return token_counter_new(
|
||||
model,
|
||||
custom_tokenizer,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue