mirror of
https://github.com/tnypxl/rollup.git
synced 2025-12-15 15:03:17 +00:00
fix: Update Anthropic SDK usage in cmd/web.go
This commit is contained in:
11
cmd/web.go
11
cmd/web.go
@@ -1,6 +1,7 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -63,10 +64,14 @@ func fetchWebContent(url string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func summarizeContent(content string) (string, error) {
|
func summarizeContent(content string) (string, error) {
|
||||||
client := anthropic.NewClient(os.Getenv("ANTHROPIC_API_KEY"))
|
client, err := anthropic.NewClient(os.Getenv("ANTHROPIC_API_KEY"))
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("error creating Anthropic client: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
resp, err := client.CreateCompletion(anthropic.CompletionRequest{
|
ctx := context.Background()
|
||||||
Model: "claude-2",
|
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),
|
Prompt: fmt.Sprintf("Human: Summarize the following web content in markdown format:\n\n%s\n\nAssistant:", content),
|
||||||
MaxTokens: 1000,
|
MaxTokens: 1000,
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user