X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/4343ca5fb6cc86eb887951f4fe16063bab29a238..c781f79f3c8cb9a7577ee1574d196988da2719b3:/compactor.go diff --git a/compactor.go b/compactor.go index 2b23901..6738955 100644 --- a/compactor.go +++ b/compactor.go @@ -15,20 +15,6 @@ const compactorTries = 5 // bytes, and a sample line as the ruler gets its content copied. var compactorRuler = strings.Repeat("-", nodeBytes) -// newCompactor returns the compactor of an agent, which sends its calls through -// client with model. instructions gives the system prompt of the agent at each -// build. tools are the tools of that agent, so a build sends the same prompt -// and tools as its turns. -func newCompactor(client *ModelClient, instructions func() (string, error), model ModelConfig, tools []ModelTool, images *ImageStore) *Compactor { - return &Compactor{ - client: client, - model: model, - instructions: instructions, - tools: tools, - images: images, - } -} - // Compactor builds the nodes of one agent with a model. A compaction is a call // like a turn, with the same system prompt and tools, so it reads them from the // prompt cache of the turns. The tools are never called. After them comes one @@ -52,6 +38,20 @@ type Compactor struct { images *ImageStore } +// newCompactor returns the compactor of an agent, which sends its calls through +// client with model. instructions gives the system prompt of the agent at each +// build. tools are the tools of that agent, so a build sends the same prompt +// and tools as its turns. +func newCompactor(client *ModelClient, instructions func() (string, error), model ModelConfig, tools []ModelTool, images *ImageStore) *Compactor { + return &Compactor{ + client: client, + model: model, + instructions: instructions, + tools: tools, + images: images, + } +} + // Summarize returns the line of the node of task. func (c *Compactor) Summarize(ctx context.Context, task Task) (string, error) { text, err := compactorTask(task) @@ -125,6 +125,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." }