From 587ab03f0c5f6edd7b128019851eef4874d6d981 Mon Sep 17 00:00:00 2001 From: "Arik Jones (aider)" Date: Tue, 3 Sep 2024 11:35:11 -0500 Subject: [PATCH] fix: Update summarizeContent function --- cmd/web.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/cmd/web.go b/cmd/web.go index 7597f15..cfe879e 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -72,12 +72,17 @@ func summarizeContent(content string) (string, error) { ctx := context.Background() msg, err := client.Messages.Create(ctx, &anthropic.MessageCreateParams{ Model: anthropic.Claude3Sonnet20240229, - MaxTokens: 1000, - System: "You are a helpful assistant that summarizes web content in markdown format.", - Messages: []anthropic.Message{ + MaxTokens: anthropic.IntPtr(1000), + System: anthropic.StringPtr("You are a helpful assistant that summarizes web content in markdown format."), + Messages: []anthropic.MessageParam{ { Role: anthropic.MessageRoleUser, - Content: fmt.Sprintf("Summarize the following web content in markdown format:\n\n%s", content), + Content: []anthropic.Content{ + { + Type: anthropic.ContentTypeText, + Text: fmt.Sprintf("Summarize the following web content in markdown format:\n\n%s", content), + }, + }, }, }, }) @@ -85,6 +90,10 @@ func summarizeContent(content string) (string, error) { return "", err } + if len(msg.Content) == 0 || msg.Content[0].Type != anthropic.ContentTypeText { + return "", fmt.Errorf("unexpected response format") + } + return msg.Content[0].Text, nil }