From 5d9dcc6df43b54b75072edab020c4fc5df16256f Mon Sep 17 00:00:00 2001 From: "Arik Jones (aider)" Date: Tue, 3 Sep 2024 11:30:38 -0500 Subject: [PATCH] feat: Update Anthropic SDK usage to latest version --- cmd/web.go | 14 ++++++++++---- go.mod | 6 +----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/cmd/web.go b/cmd/web.go index a17c6ed..7597f15 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -70,16 +70,22 @@ func summarizeContent(content string) (string, error) { } ctx := context.Background() - resp, err := client.Complete(ctx, &anthropic.CompletionRequest{ - Model: anthropic.Claude2, - Prompt: fmt.Sprintf("Human: Summarize the following web content in markdown format:\n\n%s\n\nAssistant:", content), + msg, err := client.Messages.Create(ctx, &anthropic.MessageCreateParams{ + Model: anthropic.Claude3Sonnet20240229, MaxTokens: 1000, + System: "You are a helpful assistant that summarizes web content in markdown format.", + Messages: []anthropic.Message{ + { + Role: anthropic.MessageRoleUser, + Content: fmt.Sprintf("Summarize the following web content in markdown format:\n\n%s", content), + }, + }, }) if err != nil { return "", err } - return resp.Completion, nil + return msg.Content[0].Text, nil } func saveToMarkdown(url string, content string) error { diff --git a/go.mod b/go.mod index b95e115..893f419 100644 --- a/go.mod +++ b/go.mod @@ -3,15 +3,11 @@ module github.com/tnypxl/rollup go 1.23 require ( - github.com/anthropics/anthropic-sdk-go v0.1.0-alpha.1 + github.com/anthropics/anthropic-sdk-go v0.5.0 github.com/spf13/cobra v1.8.1 ) require ( github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect - github.com/tidwall/gjson v1.14.4 // indirect - github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.1 // indirect - github.com/tidwall/sjson v1.2.5 // indirect )