reformat

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2026 License: Apache-2.0 Imports: 8 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package reformat holds the lossless components (they repack the request denser or add caching hints without losing information). Each registers via init(); a binary blank-imports components/all to pull them in.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cacheinject

type Cacheinject struct{}

Cacheinject places an Anthropic-family cache_control breakpoint on the prefix boundary so the provider's KV cache hits across turns. It is a Reformat: it adds a control directive, changes no model-visible content, and loses nothing.

v1 heuristic: mark the last content block of the last message BEFORE the newest turn (a more stable boundary than the live message). Refined with sticky prefix tracking in P5. No-op for non-Anthropic providers and when a breakpoint is already present.

func (Cacheinject) Enabled

func (Cacheinject) Enabled(c *components.Ctx) bool

func (Cacheinject) Name

func (Cacheinject) Name() string

func (Cacheinject) Reformat

type Format

type Format struct {
	// contains filtered or unexported fields
}

Format re-encodes JSON tool outputs denser without losing data (a Reformat): pretty-printed JSON is re-marshaled compact. It's strictly lossless — same value, fewer whitespace tokens — so no stash is needed. (For a denser tabular re-encoding of uniform object arrays, see the `toon` component.)

func (Format) Enabled

func (Format) Enabled(*components.Ctx) bool

func (Format) Name

func (Format) Name() string

func (*Format) Reformat

func (f *Format) Reformat(req *schemas.BifrostChatRequest, rep *components.Report, _ *components.Ctx) error

type Toon

type Toon struct {
	// contains filtered or unexported fields
}

Toon re-encodes a JSON array of uniform, flat objects as TOON (Token-Oriented Object Notation): one header listing the field names once, then one comma-separated row per element. It drops the braces, repeated keys, and quotes that dominate a JSON array's token cost. It's a Reformat (repack in place, nothing stashed): every scalar value is preserved, with one small representational simplification — JSON null renders as an empty cell (indistinguishable from ""). Only arrays whose elements share one key set and hold scalar values are encoded; anything nested, ragged, or non-array is left untouched, and the pipeline's never-worse guard reverts any case that fails to shrink.

[{"id":1,"name":"Alice"},{"id":2,"name":"Bob"}]
=>
[2]{id,name}:
1,Alice
2,Bob

func (Toon) Enabled

func (Toon) Enabled(*components.Ctx) bool

func (Toon) Name

func (Toon) Name() string

func (*Toon) Reformat

func (t *Toon) Reformat(req *schemas.BifrostChatRequest, rep *components.Report, _ *components.Ctx) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL