Skip to content

Commit

Permalink
Add another edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
sjrl committed Mar 7, 2024
1 parent 336e0b7 commit fed8475
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions haystack/utils/openai_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ def _openai_text_completion_tokenization_details(model_name: str):
or model_name == "gpt-35-turbo-0613"
):
max_tokens_limit = 4096
if model_name == "gpt-3.5-turbo-16k" or model_name == "gpt-35-turbo-16k":
max_tokens_limit = 16384

# GPT-4 models that have a different token limit than 4096
# Ref: https://platform.openai.com/docs/models/gpt-4
Expand Down
4 changes: 2 additions & 2 deletions test/utils/test_openai_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
("gpt-3.5-turbo-0613", "cl100k_base", 4096),
("gpt-3.5-turbo", "cl100k_base", 16385),
("gpt-3.5-turbo-1106", "cl100k_base", 16385),
("gpt-3.5-turbo-16k", "cl100k_base", 16384),
# GPT 4
("gpt-4-32k", "cl100k_base", 32768),
("gpt-4-1106", "cl100k_base", 128000),
Expand All @@ -32,9 +33,8 @@
("gpt-4", "cl100k_base", 8192),
# GPT-35 Azure
("gpt-35-turbo-instruct", "cl100k_base", 4096),
("gpt-35-turbo-0613", "cl100k_base", 4096),
("gpt-35-turbo", "cl100k_base", 16385),
("gpt-35-turbo-1106", "cl100k_base", 16385),
("gpt-35-turbo-16k", "cl100k_base", 16384),
# davinci and babbage
("davinci-002", "cl100k_base", 16384),
("babbage-002", "cl100k_base", 16384),
Expand Down

0 comments on commit fed8475

Please sign in to comment.