X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/0a98ccb67c3df55c0fe6d76b45afcbaa58c2eda1..87c59e9c7d6743cdd04c0d5e89d3baca173aad42:/compactor.go?ds=sidebyside diff --git a/compactor.go b/compactor.go index e7a6866..be17c15 100644 --- a/compactor.go +++ b/compactor.go @@ -65,15 +65,17 @@ func (c *Compactor) Summarize(ctx context.Context, task Task) (string, error) { instructions, err := c.instructions() if err != nil { - return "", fmt.Errorf("compact node (%d, %d): %w", task.Level, task.Index, err) + return "", err } var first []any + for _, message := range compactorTexts(task.Context, text) { first = append(first, modelUserMessage(message)) } var lines []string + note := "" for len(lines) < compactorTries { input := first @@ -82,6 +84,7 @@ func (c *Compactor) Summarize(ctx context.Context, task Task) (string, error) { } var response ModelResponse + response, err = c.client.Create(ctx, ModelRequest{ Model: c.model.Model, Effort: c.model.Effort, @@ -109,7 +112,7 @@ func (c *Compactor) Summarize(ctx context.Context, task Task) (string, error) { } if len(lines) == 0 { - return "", fmt.Errorf("compact node (%d, %d): %w", task.Level, task.Index, err) + return "", err } return compactorShortest(lines), nil @@ -157,6 +160,7 @@ func compactorTexts(view, task string) []string { whole := len(lines) - len(lines)%compactorBlock var texts []string + for n := 0; n < whole; n += compactorBlock { texts = append(texts, viewMessage(n == 0, lines[n:n+compactorBlock])) }