Skip to content

Commit a0be8ac

Browse files
authored
Merge pull request #38 from matdev83/fix/anthropic-messages-invoke-allocation-4428547483559643442
⚡ perf(anthropic): pre-allocate slice capacity in assistantMessageParam
2 parents 6841133 + 4578000 commit a0be8ac

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

  • internal/plugins/backends/protocols/anthropicmessages

internal/plugins/backends/protocols/anthropicmessages/invoke.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func assistantMessageParam(m lipapi.Message) (anthropic.MessageParam, error) {
170170
return anthropic.MessageParam{}, fmt.Errorf("anthropic: assistant message may only contain text parts in this adapter")
171171
}
172172
}
173-
var blocks []anthropic.ContentBlockParamUnion
173+
blocks := make([]anthropic.ContentBlockParamUnion, 0, len(m.Parts))
174174
for _, p := range m.Parts {
175175
if strings.TrimSpace(p.Text) == "" {
176176
continue

0 commit comments

Comments
 (0)