From 14a19fc6014a7d63e04c283aedd3fc8b12a901f3 Mon Sep 17 00:00:00 2001 From: xihajun Date: Sun, 3 Mar 2024 23:43:03 +0000 Subject: [PATCH] Disable special token restriction for claude ai --- litellm/llms/anthropic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/litellm/llms/anthropic.py b/litellm/llms/anthropic.py index 150ae0e0761..6bfedc10168 100644 --- a/litellm/llms/anthropic.py +++ b/litellm/llms/anthropic.py @@ -200,10 +200,10 @@ def completion( ## CALCULATING USAGE prompt_tokens = len( - encoding.encode(prompt) + encoding.encode(prompt,disallowed_special=()) ) ##[TODO] use the anthropic tokenizer here completion_tokens = len( - encoding.encode(model_response["choices"][0]["message"].get("content", "")) + encoding.encode(model_response["choices"][0]["message"].get("content", ""),disallowed_special=()) ) ##[TODO] use the anthropic tokenizer here model_response["created"] = int(time.time())