X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/f5c601f1801aaa276f8c335fcb51c373edc0b50c..bd7da3557dc7a17020931f5a49ed5007fa81a645:/compactor.go diff --git a/compactor.go b/compactor.go index e101428..2b06288 100644 --- a/compactor.go +++ b/compactor.go @@ -56,12 +56,12 @@ func newCompactor(client *ModelClient, instructions func() (string, error), mode func (c *Compactor) Summarize(ctx context.Context, task Task) (string, error) { text, err := compactorTask(task) if err != nil { - return "", err + return "", fmt.Errorf("prepare compaction task: %w", err) } instructions, err := c.instructions() if err != nil { - return "", err + return "", fmt.Errorf("read compaction instructions: %w", err) } source := task.Context + "\n" + text @@ -110,7 +110,11 @@ func (c *Compactor) Summarize(ctx context.Context, task Task) (string, error) { } if len(lines) == 0 { - return "", err + if err != nil { + return "", fmt.Errorf("summarize node: %w", err) + } + + return "", nil } return compactorShortest(lines), nil @@ -125,6 +129,7 @@ func compactorTask(task Task) (string, error) { %s `, task.Index, nodeBytes, compactorRuler, task.Input[0]) + if len(task.Images) > 0 { text += "\nKeep each [image FILE] name and describe its kind, visible text, amounts, names, and context." }