mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-14 04:09:09 +00:00
fix(anthropic): remove dead endpoint method, derive path prefixes from constant
- drop get_anthropic_count_tokens_endpoint (no callers since _build_count_tokens_url took over) - derive /v1/messages and /v1 prefixes from _COUNT_TOKENS_PATH via rsplit instead of independent string literals — path changes now propagate automatically Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ca73e3de44
commit
939991cb61
1 changed files with 4 additions and 5 deletions
|
|
@ -22,9 +22,6 @@ class AnthropicCountTokensConfig:
|
|||
_COUNT_TOKENS_PATH: str = "/v1/messages/count_tokens"
|
||||
_DEFAULT_ENDPOINT: str = f"https://api.anthropic.com{_COUNT_TOKENS_PATH}"
|
||||
|
||||
def get_anthropic_count_tokens_endpoint(self) -> str:
|
||||
return self._DEFAULT_ENDPOINT
|
||||
|
||||
def _build_count_tokens_url(self, api_base: Optional[str]) -> str:
|
||||
"""Return the full count_tokens URL, appending the path when a custom base is provided."""
|
||||
if not api_base:
|
||||
|
|
@ -32,9 +29,11 @@ class AnthropicCountTokensConfig:
|
|||
base = api_base.rstrip("/")
|
||||
if base.endswith(self._COUNT_TOKENS_PATH):
|
||||
return base
|
||||
if base.endswith("/v1/messages"):
|
||||
messages_prefix = self._COUNT_TOKENS_PATH.rsplit("/count_tokens", 1)[0]
|
||||
if base.endswith(messages_prefix):
|
||||
return f"{base}/count_tokens"
|
||||
if base.endswith("/v1"):
|
||||
v1_prefix = messages_prefix.rsplit("/messages", 1)[0]
|
||||
if base.endswith(v1_prefix):
|
||||
return f"{base}/messages/count_tokens"
|
||||
return f"{base}{self._COUNT_TOKENS_PATH}"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue