Skip to content

Commit 69e7216

Browse files
Merge pull request #254 from ServiceNow/fix_count_tokens
Fix count tokens
2 parents 4841c92 + 0c76a10 commit 69e7216

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/agentlab/llm/llm_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,8 @@ def get_tokenizer(model_name="gpt-4"):
516516
logging.info(f"Could not find a tokenizer for model {model_name}. Trying HuggingFace.")
517517
try:
518518
return AutoTokenizer.from_pretrained(model_name)
519-
except OSError:
520-
logging.info(f"Could not find a tokenizer for model {model_name}. Defaulting to gpt-4.")
519+
except Exception as e:
520+
logging.info(f"Could not find a tokenizer for model {model_name}: {e} Defaulting to gpt-4.")
521521
return tiktoken.encoding_for_model("gpt-4")
522522

523523

0 commit comments

Comments
 (0)