From 2a0f65f7af65083b6c5cf7182f3a4c7d0ec86576 Mon Sep 17 00:00:00 2001 From: Daniel Nouri Date: Sun, 16 Apr 2023 17:44:21 +0200 Subject: [PATCH] tiktoken: Relax Python version check (#2966) tiktoken supports Python >= 3.8, see here: https://github.com/openai/tiktoken/blob/e1c661edf3604706bb2db59cfc7bf92f73c09761/pyproject.toml#L10 Also works fine when trying locally! --- langchain/llms/openai.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/langchain/llms/openai.py b/langchain/llms/openai.py index 32edad00..f5dbafec 100644 --- a/langchain/llms/openai.py +++ b/langchain/llms/openai.py @@ -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