We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 40bd71c commit 42eb356Copy full SHA for 42eb356
libs/partners/openai/langchain_openai/chat_models/base.py
@@ -1259,8 +1259,12 @@ def _get_encoding_model(self) -> tuple[str, tiktoken.Encoding]:
1259
try:
1260
encoding = tiktoken.encoding_for_model(model)
1261
except KeyError:
1262
- model = "cl100k_base"
1263
- encoding = tiktoken.get_encoding(model)
+ encoder = "cl100k_base"
+ if self.model_name.startswith("gpt-4o") or self.model_name.startswith(
1264
+ "gpt-4.1"
1265
+ ):
1266
+ encoder = "o200k_base"
1267
+ encoding = tiktoken.get_encoding(encoder)
1268
return model, encoding
1269
1270
def get_token_ids(self, text: str) -> list[int]:
0 commit comments