Add AWS Bedrock provider support - Allow routing requests through AWS… - #19
Add AWS Bedrock provider support - Allow routing requests through AWS…#19mattbourke wants to merge 2 commits into
Conversation
… Bedrock with SigV4 authentication as an alternative to the direct Anthropic API.
|
Thanks for the contribution! Vibe reviewing 😉 the pull request, below are the issues Claude Opus 4.7 would like to see addressed before merging. Blocking issues1. Streaming cancellation is broken for both providersThe original def _iter_events_sse(response):
"""Yield parsed JSON dicts from Anthropic SSE stream."""
for line in response:
if not line or line.isspace():
continue
chunk = line.decode("utf-8")
if not chunk.startswith("data: "):
continue
chunk = chunk[6:]
if chunk.strip() == "[DONE]":
return
try:
yield json.loads(chunk)
except (json.JSONDecodeError, ValueError):
continue…iterated as Worse, when if is_cancelled():
response.close()
sublime.set_timeout(
lambda: chunk_callback(
"", is_done=True, was_cancelled=True
),
0,
)
returnThe PR's The Bedrock path is even worse because 2. Bedrock
|
Fix streaming cancellation regression on the Anthropic path: restore
non-blocking SSE polling so cancellation can fire every ~500ms, and
ensure cancellation triggers chunk_callback("", is_done=True,
was_cancelled=True) instead of leaving the response heading dangling.
Add equivalent cooperative cancellation to the Bedrock event-stream
parser via an optional should_cancel callback.
Bedrock hardening: pass timeout=30 to HTTPSConnection (was unbounded);
introduce BedrockHTTPError(status, message, error_type) so 4xx
responses route through the existing model-not-found UX; cache
resolved AWS credentials per source (settings/env/profile) honoring
their reported Expiration; suppress the AWS CLI console window on
Windows; tighten 'aws configure export-credentials' parsing to use
startswith('export ') and strip surrounding quotes; drop the
fragile response._conn attribute in favor of a small wrapper that
owns both the response and connection.
Replace fabricated Bedrock model ids with verified shipping ones
(Opus 4.6/4.5, Sonnet 4.6/4.5, Haiku 4.5) plus their us./eu./apac./
global. inference-profile equivalents.
Validate the provider setting and warn-and-fall-back on unknown
values rather than silently routing Bedrock-style ids to the
Anthropic endpoint.
Normalize api/bedrock.py to project conventions: double quotes,
f-strings, line length, alphabetical imports, Google-style
docstrings on public functions. Document the AWS CLI requirement
and credential caching in the settings file. Revert the unrelated
re-quoting in chat/ask_question.py.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Hi Barry, Address PR review feedback for AWS Bedrock provider Bedrock hardening: pass timeout=30 to HTTPSConnection (was unbounded); Replace fabricated Bedrock model ids with verified shipping ones Validate the provider setting and warn-and-fall-back on unknown Normalize api/bedrock.py to project conventions: double quotes, Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com |
Here is the code to allow routing requests through AWS Bedrock.
This is heavily Vibe coded, the below is from Claude.
Add AWS Bedrock provider support
Summary
Adds AWS Bedrock as an alternative provider for Claudette, allowing users to route Claude API requests through AWS Bedrock instead of the direct Anthropic API. This is useful for
organizations that require requests to go through their AWS account (compliance, billing consolidation, VPC endpoints, etc.).
Changes
endpoints.
Anthropic API. Refactors the streaming loop to use a shared event iterator pattern for both providers. Adds a static list of available Bedrock model IDs for the model switcher.
AWS credential resolution order
Usage
No API key is required when using Bedrock — authentication is handled via AWS credentials.