diff --git a/README.md b/README.md index b344ab7e..b98c1830 100644 --- a/README.md +++ b/README.md @@ -203,6 +203,8 @@ OpenCode supports a variety of AI models from different providers: ### Anthropic +- Claude 4 Sonnet +- Claude 4 Opus - Claude 3.5 Sonnet - Claude 3.5 Haiku - Claude 3.7 Sonnet diff --git a/cmd/schema/README.md b/cmd/schema/README.md index 93ebe9f0..b6762663 100644 --- a/cmd/schema/README.md +++ b/cmd/schema/README.md @@ -61,4 +61,4 @@ Here's an example configuration that conforms to the schema: } } } -``` \ No newline at end of file +``` diff --git a/go.mod b/go.mod index dc8eaadd..82994450 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/JohannesKaufmann/html-to-markdown v1.6.0 github.com/PuerkitoBio/goquery v1.9.2 github.com/alecthomas/chroma/v2 v2.15.0 - github.com/anthropics/anthropic-sdk-go v0.2.0-beta.2 + github.com/anthropics/anthropic-sdk-go v1.4.0 github.com/aymanbagabas/go-udiff v0.2.0 github.com/bmatcuk/doublestar/v4 v4.8.1 github.com/catppuccin/go v0.3.0 diff --git a/go.sum b/go.sum index d5396bb8..8b7e3074 100644 --- a/go.sum +++ b/go.sum @@ -26,8 +26,8 @@ github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss= github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU= -github.com/anthropics/anthropic-sdk-go v0.2.0-beta.2 h1:h7qxtumNjKPWFv1QM/HJy60MteeW23iKeEtBoY7bYZk= -github.com/anthropics/anthropic-sdk-go v0.2.0-beta.2/go.mod h1:AapDW22irxK2PSumZiQXYUFvsdQgkwIWlpESweWZI/c= +github.com/anthropics/anthropic-sdk-go v1.4.0 h1:fU1jKxYbQdQDiEXCxeW5XZRIOwKevn/PMg8Ay1nnUx0= +github.com/anthropics/anthropic-sdk-go v1.4.0/go.mod h1:AapDW22irxK2PSumZiQXYUFvsdQgkwIWlpESweWZI/c= github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4= github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= github.com/aws/aws-sdk-go-v2 v1.30.3 h1:jUeBtG0Ih+ZIFH0F4UkmL9w3cSpaMv9tYYDbzILP8dY= diff --git a/internal/llm/provider/anthropic.go b/internal/llm/provider/anthropic.go index e51a3412..badf6a3a 100644 --- a/internal/llm/provider/anthropic.go +++ b/internal/llm/provider/anthropic.go @@ -67,7 +67,7 @@ func (a *anthropicClient) convertMessages(messages []message.Message) (anthropic case message.User: content := anthropic.NewTextBlock(msg.Content().String()) if cache && !a.options.disableCache { - content.OfRequestTextBlock.CacheControl = anthropic.CacheControlEphemeralParam{ + content.OfText.CacheControl = anthropic.CacheControlEphemeralParam{ Type: "ephemeral", } } @@ -85,7 +85,7 @@ func (a *anthropicClient) convertMessages(messages []message.Message) (anthropic if msg.Content().String() != "" { content := anthropic.NewTextBlock(msg.Content().String()) if cache && !a.options.disableCache { - content.OfRequestTextBlock.CacheControl = anthropic.CacheControlEphemeralParam{ + content.OfText.CacheControl = anthropic.CacheControlEphemeralParam{ Type: "ephemeral", } } @@ -98,7 +98,7 @@ func (a *anthropicClient) convertMessages(messages []message.Message) (anthropic if err != nil { continue } - blocks = append(blocks, anthropic.ContentBlockParamOfRequestToolUseBlock(toolCall.ID, inputMap, toolCall.Name)) + blocks = append(blocks, anthropic.NewToolUseBlock(toolCall.ID, inputMap, toolCall.Name)) } if len(blocks) == 0 { @@ -167,17 +167,12 @@ func (a *anthropicClient) preparedMessages(messages []anthropic.MessageParam, to temperature := anthropic.Float(0) if isUser { for _, m := range lastMessage.Content { - if m.OfRequestTextBlock != nil && m.OfRequestTextBlock.Text != "" { - messageContent = m.OfRequestTextBlock.Text + if m.OfText != nil && m.OfText.Text != "" { + messageContent = m.OfText.Text } } if messageContent != "" && a.options.shouldThink != nil && a.options.shouldThink(messageContent) { - thinkingParam = anthropic.ThinkingConfigParamUnion{ - OfThinkingConfigEnabled: &anthropic.ThinkingConfigEnabledParam{ - BudgetTokens: int64(float64(a.providerOptions.maxTokens) * 0.8), - Type: "enabled", - }, - } + thinkingParam = anthropic.ThinkingConfigParamOfEnabled(int64(float64(a.providerOptions.maxTokens) * 0.8)) temperature = anthropic.Float(1) } }