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 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,
}) })