mirror of
https://github.com/tnypxl/rollup.git
synced 2025-12-15 23:13:22 +00:00
fix: Update summarizeContent function
This commit is contained in:
17
cmd/web.go
17
cmd/web.go
@@ -72,12 +72,17 @@ func summarizeContent(content string) (string, error) {
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
msg, err := client.Messages.Create(ctx, &anthropic.MessageCreateParams{
|
msg, err := client.Messages.Create(ctx, &anthropic.MessageCreateParams{
|
||||||
Model: anthropic.Claude3Sonnet20240229,
|
Model: anthropic.Claude3Sonnet20240229,
|
||||||
MaxTokens: 1000,
|
MaxTokens: anthropic.IntPtr(1000),
|
||||||
System: "You are a helpful assistant that summarizes web content in markdown format.",
|
System: anthropic.StringPtr("You are a helpful assistant that summarizes web content in markdown format."),
|
||||||
Messages: []anthropic.Message{
|
Messages: []anthropic.MessageParam{
|
||||||
{
|
{
|
||||||
Role: anthropic.MessageRoleUser,
|
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
|
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
|
return msg.Content[0].Text, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user