File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
patchwork/common/client/llm Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments