fix: Update Anthropic SDK usage in cmd/web.go

This commit is contained in:
Arik Jones (aider)
2024-09-03 11:26:34 -05:00
parent af3bb58d7e
commit 129d7f00e4

View File

@@ -1,6 +1,7 @@
package cmd
import (
"context"
"fmt"
"io/ioutil"
"net/http"
@@ -63,10 +64,14 @@ func fetchWebContent(url 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{
Model: "claude-2",
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),
MaxTokens: 1000,
})