@@ -26,7 +26,7 @@ def test_token_counter(self):
2626 ]
2727
2828 # check if test covers all models (increase if new models are added)
29- assert len (OpenAIChatModel .__args__ ) == 14 # type: ignore
29+ assert len (OpenAIChatModel .__args__ ) == 16 # type: ignore
3030
3131 client = AsyncTypeOpenAI (api_key = "mock" )
3232
@@ -42,9 +42,34 @@ def test_token_counter(self):
4242 assert client .chat .completions .num_tokens_from_messages (test_messages , model = "gpt-4-32k" ) == 27
4343 assert client .chat .completions .num_tokens_from_messages (test_messages , model = "gpt-4-32k-0314" ) == 27
4444 assert client .chat .completions .num_tokens_from_messages (test_messages , model = "gpt-4-32k-0613" ) == 27
45+ assert client .chat .completions .num_tokens_from_messages (test_messages , model = "gpt-4-turbo-preview" ) == 27
4546 assert client .chat .completions .num_tokens_from_messages (test_messages , model = "gpt-4-1106-preview" ) == 27
47+ assert client .chat .completions .num_tokens_from_messages (test_messages , model = "gpt-4-0125-preview" ) == 27
4648 assert client .chat .completions .num_tokens_from_messages (test_messages , model = "gpt-4-vision-preview" ) == 27
4749
50+ def test_max_token_counter (self ):
51+ # check if test covers all models (increase if new models are added)
52+ assert len (OpenAIChatModel .__args__ ) == 16 # type: ignore
53+
54+ client = AsyncTypeOpenAI (api_key = "mock" )
55+
56+ assert client .chat .completions .max_tokens_of_model ("gpt-3.5-turbo" ) == 4096
57+ assert client .chat .completions .max_tokens_of_model ("gpt-3.5-turbo-0301" ) == 4096
58+ assert client .chat .completions .max_tokens_of_model ("gpt-3.5-turbo-0613" ) == 4096
59+ assert client .chat .completions .max_tokens_of_model ("gpt-3.5-turbo-1106" ) == 16384
60+ assert client .chat .completions .max_tokens_of_model ("gpt-3.5-turbo-16k" ) == 16384
61+ assert client .chat .completions .max_tokens_of_model ("gpt-3.5-turbo-16k-0613" ) == 16384
62+ assert client .chat .completions .max_tokens_of_model ("gpt-4" ) == 8192
63+ assert client .chat .completions .max_tokens_of_model ("gpt-4-0314" ) == 8192
64+ assert client .chat .completions .max_tokens_of_model ("gpt-4-0613" ) == 8192
65+ assert client .chat .completions .max_tokens_of_model ("gpt-4-32k" ) == 32768
66+ assert client .chat .completions .max_tokens_of_model ("gpt-4-32k-0314" ) == 32768
67+ assert client .chat .completions .max_tokens_of_model ("gpt-4-32k-0613" ) == 32768
68+ assert client .chat .completions .max_tokens_of_model ("gpt-4-turbo-preview" ) == 128_000
69+ assert client .chat .completions .max_tokens_of_model ("gpt-4-1106-preview" ) == 128_000
70+ assert client .chat .completions .max_tokens_of_model ("gpt-4-0125-preview" ) == 128_000
71+ assert client .chat .completions .max_tokens_of_model ("gpt-4-vision-preview" ) == 128_000
72+
4873 # -
4974
5075 @pytest .fixture
0 commit comments