feat: add Claude Sonnet 4.5 support with global cross-region inference (#180)
This commit adds comprehensive support for Claude Sonnet 4.5 (claude-sonnet-4-5-20250929),
Anthropic's most intelligent model with enhanced coding capabilities and complex agent support.
Changes:
- Added global cross-region inference profile discovery (global.anthropic.*)
- Fixed temperature/topP compatibility for Claude Sonnet 4.5 (model doesn't support both simultaneously)
- Fixed reasoning_effort parameter handling to prevent KeyError
- Added extended thinking/interleaved thinking support via extra_body parameter
- Updated documentation with Claude Sonnet 4.5 examples (English and Chinese)
- Updated README with Sonnet 4.5 announcement
Technical Details:
- src/api/models/bedrock.py: Added global profile support in list_bedrock_models()
- src/api/models/bedrock.py: Added Claude Sonnet 4.5 detection to remove topP parameter
- src/api/models/bedrock.py: Changed pop("topP") to pop("topP", None) to prevent KeyError
- docs/Usage.md: Added Chat Completions section with Sonnet 4.5 examples
- docs/Usage.md: Updated Interleaved thinking section with Sonnet 4.5 examples
- docs/Usage_CN.md: Added Chinese versions of all Sonnet 4.5 documentation
Model ID: global.anthropic.claude-sonnet-4-5-20250929-v1:0
This commit is contained in:
@@ -158,6 +158,11 @@ def list_bedrock_models() -> dict:
|
||||
if profile_id in profile_list:
|
||||
model_list[profile_id] = {"modalities": input_modalities}
|
||||
|
||||
# Add global cross-region inference profiles
|
||||
global_profile_id = "global." + model_id
|
||||
if global_profile_id in profile_list:
|
||||
model_list[global_profile_id] = {"modalities": input_modalities}
|
||||
|
||||
# Add application inference profiles (emit all profiles for this model)
|
||||
if model_id in app_profiles_by_model:
|
||||
for profile_arn in app_profiles_by_model[model_id]:
|
||||
@@ -521,6 +526,11 @@ class BedrockModel(BaseChatModel):
|
||||
"topP": chat_request.top_p,
|
||||
}
|
||||
|
||||
# Claude Sonnet 4.5 doesn't support both temperature and topP
|
||||
# Remove topP for this model
|
||||
if "claude-sonnet-4-5" in chat_request.model.lower():
|
||||
inference_config.pop("topP", None)
|
||||
|
||||
if chat_request.stop is not None:
|
||||
stop = chat_request.stop
|
||||
if isinstance(stop, str):
|
||||
@@ -547,7 +557,7 @@ class BedrockModel(BaseChatModel):
|
||||
)
|
||||
inference_config["maxTokens"] = max_tokens
|
||||
# unset topP - Not supported
|
||||
inference_config.pop("topP")
|
||||
inference_config.pop("topP", None)
|
||||
|
||||
args["additionalModelRequestFields"] = {
|
||||
"reasoning_config": {"type": "enabled", "budget_tokens": budget_tokens}
|
||||
@@ -573,8 +583,12 @@ class BedrockModel(BaseChatModel):
|
||||
args["toolConfig"] = tool_config
|
||||
# add Additional fields to enable extend thinking
|
||||
if chat_request.extra_body:
|
||||
# reasoning_config will not be used
|
||||
# reasoning_config will not be used
|
||||
args["additionalModelRequestFields"] = chat_request.extra_body
|
||||
# Extended thinking doesn't support both temperature and topP
|
||||
# Remove topP to avoid validation error
|
||||
if "thinking" in chat_request.extra_body:
|
||||
inference_config.pop("topP", None)
|
||||
return args
|
||||
|
||||
def _create_response(
|
||||
|
||||
Reference in New Issue
Block a user