fix: Update summarizeContent function

This commit is contained in:
Arik Jones (aider)
2024-09-03 11:35:11 -05:00
parent 5d9dcc6df4
commit 587ab03f0c

View File

@@ -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
}