tiktoken: Relax Python version check (#2966)

tiktoken supports Python >= 3.8, see here:

e1c661edf3/pyproject.toml (L10)

Also works fine when trying locally!
This commit is contained in:
Daniel Nouri 2023-04-16 17:44:21 +02:00 committed by GitHub
parent aead062a70
commit 2a0f65f7af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -435,8 +435,8 @@ class BaseOpenAI(BaseLLM):
def get_num_tokens(self, text: str) -> int:
"""Calculate num tokens with tiktoken package."""
# tiktoken NOT supported for Python 3.8 or below
if sys.version_info[1] <= 8:
# tiktoken NOT supported for Python < 3.8
if sys.version_info[1] < 8:
return super().get_num_tokens(text)
try:
import tiktoken
@ -770,8 +770,8 @@ class OpenAIChat(BaseLLM):
def get_num_tokens(self, text: str) -> int:
"""Calculate num tokens with tiktoken package."""
# tiktoken NOT supported for Python 3.8 or below
if sys.version_info[1] <= 8:
# tiktoken NOT supported for Python < 3.8
if sys.version_info[1] < 8:
return super().get_num_tokens(text)
try:
import tiktoken