Skip to content

Commit

Permalink
chore(bedrock/vertex): explicit error for unsupported messages endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertCraigie authored and stainless-app[bot] committed Dec 17, 2024
1 parent 45c28dd commit c17d68e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/anthropic/lib/bedrock/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from ..._compat import model_copy
from ..._version import __version__
from ..._streaming import Stream, AsyncStream
from ..._exceptions import APIStatusError
from ..._exceptions import AnthropicError, APIStatusError
from ..._base_client import (
DEFAULT_MAX_RETRIES,
BaseClient,
Expand Down Expand Up @@ -55,6 +55,12 @@ def _prepare_options(input_options: FinalRequestOptions) -> FinalRequestOptions:
else:
options.url = f"/model/{model}/invoke"

if options.url.startswith('/v1/messages/batches'):
raise AnthropicError('The Batch API is not supported in Bedrock yet')

if options.url == '/v1/messages/count_tokens':
raise AnthropicError('Token counting is not supported in Bedrock yet')

return options


Expand Down
5 changes: 4 additions & 1 deletion src/anthropic/lib/vertex/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from ..._models import FinalRequestOptions
from ..._version import __version__
from ..._streaming import Stream, AsyncStream
from ..._exceptions import APIStatusError
from ..._exceptions import AnthropicError, APIStatusError
from ..._base_client import (
DEFAULT_MAX_RETRIES,
DEFAULT_CONNECTION_LIMITS,
Expand Down Expand Up @@ -452,4 +452,7 @@ def _prepare_options(input_options: FinalRequestOptions, *, project_id: str | No

options.url = f"/projects/{project_id}/locations/{region}/publishers/anthropic/models/count-tokens:rawPredict"

if options.url.startswith('/v1/messages/batches'):
raise AnthropicError('The Batch API is not supported in the Vertex client yet')

return options

0 comments on commit c17d68e

Please sign in to comment.