Skip to content

Commit 7dda47e

Browse files
author
patched.codes[bot]
committed
Patched patchwork/common/client/llm/openai_.py
1 parent a4cfca0 commit 7dda47e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

patchwork/common/client/llm/openai_.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class OpenAiLlmClient(LlmClient):
3636
"o1-mini": 128_000,
3737
"gpt-4o-mini": 128_000,
3838
"gpt-4o": 128_000,
39+
"o3-mini": 128_000,
3940
}
4041

4142
def __init__(self, api_key: str, base_url=None, **kwargs):
@@ -87,7 +88,12 @@ def is_prompt_supported(
8788

8889
model_limit = self.__get_model_limits(model)
8990
token_count = 0
90-
encoding = tiktoken.encoding_for_model(model)
91+
try:
92+
encoding = tiktoken.encoding_for_model(model)
93+
except KeyError:
94+
# Fallback to gpt-4 tokenizer if model-specific tokenizer is not found
95+
encoding = tiktoken.encoding_for_model("gpt-4")
96+
9197
for message in messages:
9298
message_token_count = len(encoding.encode(message.get("content")))
9399
token_count = token_count + message_token_count

0 commit comments

Comments
 (0)