mirror of
https://github.com/tnypxl/rollup.git
synced 2025-12-15 15:03:17 +00:00
feat: Update Anthropic SDK usage to latest version
This commit is contained in:
14
cmd/web.go
14
cmd/web.go
@@ -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
6
go.mod
@@ -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
|
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user