mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-12 02:19:05 +08:00
feat: disable token counting in large language models for performance testing
Signed-off-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
parent
307ebbb4ff
commit
94c08462a1
@ -537,7 +537,6 @@ if you are not sure about the structure.
|
|||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def get_num_tokens(
|
def get_num_tokens(
|
||||||
self,
|
self,
|
||||||
model: str,
|
model: str,
|
||||||
@ -554,7 +553,8 @@ if you are not sure about the structure.
|
|||||||
:param tools: tools for tool calling
|
:param tools: tools for tool calling
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
# Disable the token count in LLMs for profermance testing.
|
||||||
|
return 0
|
||||||
|
|
||||||
def enforce_stop_tokens(self, text: str, stop: list[str]) -> str:
|
def enforce_stop_tokens(self, text: str, stop: list[str]) -> str:
|
||||||
"""Cut off the text as soon as any stop words occur."""
|
"""Cut off the text as soon as any stop words occur."""
|
||||||
|
@ -25,8 +25,7 @@ class GPT2Tokenizer:
|
|||||||
# future = _executor.submit(GPT2Tokenizer._get_num_tokens_by_gpt2, text)
|
# future = _executor.submit(GPT2Tokenizer._get_num_tokens_by_gpt2, text)
|
||||||
# result = future.result()
|
# result = future.result()
|
||||||
# return cast(int, result)
|
# return cast(int, result)
|
||||||
# return GPT2Tokenizer._get_num_tokens_by_gpt2(text)
|
return GPT2Tokenizer._get_num_tokens_by_gpt2(text)
|
||||||
return 0
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_encoder() -> Any:
|
def get_encoder() -> Any:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user