Skip to content

Commit ce6d5b0

Browse files
committed
added logic and documentation updates for claude 4 models
1 parent 7fdde20 commit ce6d5b0

6 files changed

Lines changed: 84 additions & 34 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ Invoke-AmazonNovaTextModel -Message 'Explain zero-point energy.' -ModelID 'amazo
130130
```powershell
131131
#------------------------------------------------------------------------------------------------
132132
# Sends a text message to the on-demand Anthropic model in the specified AWS region and returns the response.
133-
Invoke-AnthropicModel -Message 'Explain zero-point energy.' -ModelID 'anthropic.claude-3-5-haiku-20241022-v1:0' -Credential $awsCredential -Region 'us-west-2'
133+
Invoke-AnthropicModel -Message 'Explain zero-point energy.' -ModelID 'anthropic.claude-sonnet-4-20250514-v1:0' -Credential $awsCredential -Region 'us-west-2'
134134
#------------------------------------------------------------------------------------------------
135135
# Sending a media file to an Anthropic model and retrieving the response
136-
Invoke-AnthropicModel -Message 'What can you tell me about this picture?' -ModelID 'anthropic.claude-3-5-sonnet-20241022-v2:0' -MediaPath 'C:\images\tanagra.jpg' -Credential $awsCredential -Region 'us-west-2'
136+
Invoke-AnthropicModel -Message 'What can you tell me about this picture?' -ModelID 'anthropic.claude-sonnet-4-20250514-v1:0' -MediaPath 'C:\images\tanagra.jpg' -Credential $awsCredential -Region 'us-west-2'
137137
#------------------------------------------------------------------------------------------------
138138
```
139139

docs/Invoke-AnthropicModel.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,23 @@ See the pwshBedrock documentation for more information on Function Calling and t
6969
### EXAMPLE 1
7070

7171
```powershell
72-
Invoke-AnthropicModel -Message 'Explain zero-point energy.' -ModelID 'anthropic.claude-3-5-haiku-20241022-v1:0' -Credential $awsCredential -Region 'us-west-2'
72+
Invoke-AnthropicModel -Message 'Explain zero-point energy.' -ModelID 'anthropic.claude-sonnet-4-20250514-v1:0' -Credential $awsCredential -Region 'us-west-2'
7373
```
7474

7575
Sends a text message to the on-demand Anthropic model in the specified AWS region and returns the response.
7676

7777
### EXAMPLE 2
7878

7979
```powershell
80-
Invoke-AnthropicModel -Message 'Explain zero-point energy.' -ModelID 'anthropic.claude-3-5-haiku-20241022-v1:0' -ProfileName default -Region 'us-west-2' -ReturnFullObject
80+
Invoke-AnthropicModel -Message 'Explain zero-point energy.' -ModelID 'anthropic.claude-sonnet-4-20250514-v1:0' -ProfileName default -Region 'us-west-2' -ReturnFullObject
8181
```
8282

8383
Sends a text message to the on-demand Anthropic model in the specified AWS region and returns the full response object.
8484

8585
### EXAMPLE 3
8686

8787
```powershell
88-
Invoke-AnthropicModel -Message 'Explain zero-point energy.' -ModelID 'anthropic.claude-3-5-haiku-20241022-v1:0' -ProfileName default -Region 'us-west-2' -NoContextPersist
88+
Invoke-AnthropicModel -Message 'Explain zero-point energy.' -ModelID 'anthropic.claude-sonnet-4-20250514-v1:0' -ProfileName default -Region 'us-west-2' -NoContextPersist
8989
```
9090

9191
Sends a text message to the on-demand Anthropic model in the specified AWS region without persisting the conversation context history.
@@ -96,7 +96,7 @@ This is useful for one-off interactions.
9696
```powershell
9797
$invokeAnthropicModelSplat = @{
9898
Message = 'What can you tell me about this picture? Is it referencing something?'
99-
ModelID = 'anthropic.claude-3-sonnet-20240229-v1:0'
99+
ModelID = 'anthropic.claude-sonnet-4-20250514-v1:0'
100100
MediaPath = 'C:\images\tanagra.jpg'
101101
AccessKey = 'xxxxxxxxxxxxxxxxxxxx'
102102
SecretKey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
@@ -112,7 +112,7 @@ Sends a text message with a media file to the on-demand Anthropic model in the s
112112
```powershell
113113
$invokeAnthropicModelSplat = @{
114114
Message = 'Give a brief synopsis to your class of students of what this picture represented a hundreds years ago.'
115-
ModelID = 'anthropic.claude-3-sonnet-20240229-v1:0'
115+
ModelID = 'anthropic.claude-sonnet-4-20250514-v1:0'
116116
MediaPath = 'C:\images\tanagra.jpg'
117117
Temperature = 1
118118
SystemPrompt = 'You are a historian from the future who has studied the provided photo for many years.'
@@ -131,7 +131,7 @@ Temperature is set to 1 for creative responses.
131131
```powershell
132132
$invokeAnthropicModelSplat = @{
133133
Message = 'Can you name all of the Star Fleet captains featured in the various shows over the years?'
134-
ModelID = 'anthropic.claude-3-sonnet-20240229-v1:0'
134+
ModelID = 'anthropic.claude-sonnet-4-20250514-v1:0'
135135
SystemPrompt = 'You are an expert on all things Star Trek, having studied the show for decades. You often win Star Trek Trivia contests and enjoy sharing your vast knowledge of Star Trek with others.'
136136
Temperature = 1
137137
StopSequences = 'Picard'
@@ -152,7 +152,7 @@ Stop sequences are provided to stop the model from generating more text when it
152152
```powershell
153153
$invokeAnthropicModelSplat = @{
154154
Message = 'Can you name all of the Star Fleet captains featured in the various shows over the years?'
155-
ModelID = 'anthropic.claude-3-7-sonnet-20250219-v1:0'
155+
ModelID = 'anthropic.claude-opus-4-20250514-v1:0'
156156
SystemPrompt = 'You are an expert on all things Star Trek, having studied the show for decades. You often win Star Trek Trivia contests and enjoy sharing your vast knowledge of Star Trek with others.'
157157
Thinking = $true
158158
ThinkingBudgetTokens = 2000
@@ -184,7 +184,7 @@ Reference the pwshBedrock documentation for more information on the custom conve
184184
```powershell
185185
$invokeAnthropicModelSplat = @{
186186
Message = 'Can you name all of the Star Fleet captains featured in the various shows over the years?'
187-
ModelID = 'anthropic.claude-3-5-sonnet-20240620-v1:0'
187+
ModelID = 'anthropic.claude-sonnet-4-20250514-v1:0'
188188
SystemPrompt = 'You are an expert on all things Star Trek, having studied the show for decades. You often win Star Trek Trivia contests and enjoy sharing your vast knowledge of Star Trek with others.'
189189
Tools = $starTrekTriviaFunctionTool
190190
ToolChoice = 'auto'
@@ -206,7 +206,7 @@ The tool is a function that provides Star Trek trivia information.
206206
```powershell
207207
$invokeAnthropicModelSplat = @{
208208
ToolsResults = $standardToolResult
209-
ModelID = 'anthropic.claude-3-5-sonnet-20240620-v1:0'
209+
ModelID = 'anthropic.claude-sonnet-4-20250514-v1:0'
210210
Credential = $credential
211211
Region = 'us-west-2'
212212
}
@@ -434,7 +434,7 @@ Accept wildcard characters: False
434434
### -Thinking
435435
436436
Claude will show its reasoning process through thinking content blocks in the response.
437-
This switch is only available for Claude 3.7 model.
437+
This switch is available for Claude 3.7 and Claude 4 models.
438438
Thinking is not compatible with temperature, top_p, or top_k modifications, as well as forced tool use.
439439
Thinking is only viewable in the full response object, and will not be included in the message history context or the message reply.
440440
@@ -455,7 +455,7 @@ Accept wildcard characters: False
455455
Maximum number of tokens that Claude may use for its internal reasoning process.
456456
thinking budget tokens must always be less than the max tokens you specify in your request.
457457
This is a required parameter when using the Thinking switch.
458-
This parameter is only available for Claude 3.7 model.
458+
This parameter is available for Claude 3.7 and Claude 4 models.
459459
This parameter has no effect if not using the Thinking switch.
460460
461461
```yaml
@@ -732,7 +732,7 @@ Use the -ReturnFullObject parameter to get the full response object, which inclu
732732
733733
[https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-anthropic-claude-messages.html](https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-anthropic-claude-messages.html)
734734
735-
[https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-anthropic-claude-37.html](https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-anthropic-claude-37.html)
735+
[https://docs.aws.amazon.com/bedrock/latest/userguide/claude-messages-extended-thinking.html](https://docs.aws.amazon.com/bedrock/latest/userguide/claude-messages-extended-thinking.html)
736736
737737
[https://docs.anthropic.com/en/docs/models-overview](https://docs.anthropic.com/en/docs/models-overview)
738738

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ Invoke-AmazonNovaTextModel -Message 'Explain zero-point energy.' -ModelID 'amazo
110110
```powershell
111111
#------------------------------------------------------------------------------------------------
112112
# Sends a text message to the on-demand Anthropic model in the specified AWS region and returns the response.
113-
Invoke-AnthropicModel -Message 'Explain zero-point energy.' -ModelID 'anthropic.claude-3-5-haiku-20241022-v1:0' -Credential $awsCredential -Region 'us-west-2'
113+
Invoke-AnthropicModel -Message 'Explain zero-point energy.' -ModelID 'anthropic.claude-sonnet-4-20250514-v1:0' -Credential $awsCredential -Region 'us-west-2'
114114
#------------------------------------------------------------------------------------------------
115115
# Sending a media file to an Anthropic model and retrieving the response
116-
Invoke-AnthropicModel -Message 'What can you tell me about this picture?' -ModelID 'anthropic.claude-3-5-sonnet-20241022-v2:0' -MediaPath 'C:\images\tanagra.jpg' -Credential $awsCredential -Region 'us-west-2'
116+
Invoke-AnthropicModel -Message 'What can you tell me about this picture?' -ModelID 'anthropic.claude-sonnet-4-20250514-v1:0' -MediaPath 'C:\images\tanagra.jpg' -Credential $awsCredential -Region 'us-west-2'
117117
#------------------------------------------------------------------------------------------------
118118
```
119119

src/Tests/Integration/Anthropic.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ InModuleScope 'pwshBedrock' {
7777
Write-Verbose -Message $eval.content.text
7878
} #it
7979

80-
It 'should return an object with thinking and reasoning when provided a standard message for <_.ModelID>' -Foreach ($script:anthropicModelInfo | Where-Object { $_.ModelID -eq 'anthropic.claude-3-7-sonnet-20250219-v1:0' }) {
80+
It 'should return an object with thinking and reasoning when provided a standard message for <_.ModelID>' -Foreach ($script:anthropicModelInfo | Where-Object { $_.ModelID -eq 'anthropic.claude-3-7-sonnet-20250219-v1:0' -or $_.ModelID -like 'anthropic.claude-*-4*' }) {
8181
$ModelID = $_.ModelID
8282
$invokeAnthropicModelSplat = @{
8383
Message = 'Return the number 1 as a string'

src/Tests/Unit/Public/Invoke-AnthropicModel.Tests.ps1

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ InModuleScope 'pwshBedrock' {
547547
} | Should -Throw
548548
} #it
549549

550-
It 'should throw if Thinking parameter is used with a non-Claude 3.7 model' {
550+
It 'should throw if Thinking parameter is used with an unsupported model' {
551551
{
552552
$invokeAnthropicModelSplat = @{
553553
Message = 'Tell me about the universe.'
@@ -559,7 +559,7 @@ InModuleScope 'pwshBedrock' {
559559
Region = 'us-west-2'
560560
}
561561
Invoke-AnthropicModel @invokeAnthropicModelSplat
562-
} | Should -Throw -ExpectedMessage 'Thinking is only available for the Claude 3.7 model.'
562+
} | Should -Throw -ExpectedMessage 'Thinking is only available for Claude 3.7 and Claude 4 models.'
563563
} #it
564564

565565
It 'should throw if Thinking parameter is used without ThinkingBudgetTokens' {
@@ -983,6 +983,51 @@ InModuleScope 'pwshBedrock' {
983983
Invoke-AnthropicModel @invokeAnthropicModelSplat | Should -InvokeVerifiable
984984
} #it
985985

986+
It 'should successfully use Thinking with Claude 4 Opus model' {
987+
$invokeAnthropicModelSplat = @{
988+
Message = 'Explain quantum mechanics.'
989+
ModelID = 'anthropic.claude-opus-4-20250514-v1:0'
990+
Thinking = $true
991+
ThinkingBudgetTokens = 2000
992+
AccessKey = 'ak'
993+
SecretKey = 'sk'
994+
Region = 'us-west-2'
995+
}
996+
$result = Invoke-AnthropicModel @invokeAnthropicModelSplat
997+
$result | Should -BeOfType [System.String]
998+
$result | Should -BeExactly 'Hello! I am an AI language model.'
999+
} #it
1000+
1001+
It 'should successfully use Thinking with Claude 4 Sonnet model' {
1002+
$invokeAnthropicModelSplat = @{
1003+
Message = 'Explain quantum mechanics.'
1004+
ModelID = 'anthropic.claude-sonnet-4-20250514-v1:0'
1005+
Thinking = $true
1006+
ThinkingBudgetTokens = 1500
1007+
AccessKey = 'ak'
1008+
SecretKey = 'sk'
1009+
Region = 'us-west-2'
1010+
}
1011+
$result = Invoke-AnthropicModel @invokeAnthropicModelSplat
1012+
$result | Should -BeOfType [System.String]
1013+
$result | Should -BeExactly 'Hello! I am an AI language model.'
1014+
} #it
1015+
1016+
It 'should successfully use Thinking with Claude 3.7 model' {
1017+
$invokeAnthropicModelSplat = @{
1018+
Message = 'Explain quantum mechanics.'
1019+
ModelID = 'anthropic.claude-3-7-sonnet-20250219-v1:0'
1020+
Thinking = $true
1021+
ThinkingBudgetTokens = 1024
1022+
AccessKey = 'ak'
1023+
SecretKey = 'sk'
1024+
Region = 'us-west-2'
1025+
}
1026+
$result = Invoke-AnthropicModel @invokeAnthropicModelSplat
1027+
$result | Should -BeOfType [System.String]
1028+
$result | Should -BeExactly 'Hello! I am an AI language model.'
1029+
} #it
1030+
9861031
} #context_Success
9871032

9881033
} #describe_Invoke-AnthropicModel

0 commit comments

Comments
 (0)