feat: Update Anthropic SDK usage to latest version

This commit is contained in:
Arik Jones (aider)
2024-09-03 11:30:38 -05:00
parent f0dce84dbd
commit 5d9dcc6df4
2 changed files with 11 additions and 9 deletions

View File

@@ -70,16 +70,22 @@ func summarizeContent(content string) (string, error) {
} }
ctx := context.Background() ctx := context.Background()
resp, err := client.Complete(ctx, &anthropic.CompletionRequest{ msg, err := client.Messages.Create(ctx, &anthropic.MessageCreateParams{
Model: anthropic.Claude2, Model: anthropic.Claude3Sonnet20240229,
Prompt: fmt.Sprintf("Human: Summarize the following web content in markdown format:\n\n%s\n\nAssistant:", content),
MaxTokens: 1000, 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 { if err != nil {
return "", err return "", err
} }
return resp.Completion, nil return msg.Content[0].Text, nil
} }
func saveToMarkdown(url string, content string) error { func saveToMarkdown(url string, content string) error {

6
go.mod
View File

@@ -3,15 +3,11 @@ module github.com/tnypxl/rollup
go 1.23 go 1.23
require ( 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 github.com/spf13/cobra v1.8.1
) )
require ( require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // 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
) )