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 ¶
func (Cacheinject) Reformat(req *schemas.BifrostChatRequest, rep *components.Report, _ *components.Ctx) error
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) 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) Reformat ¶
func (t *Toon) Reformat(req *schemas.BifrostChatRequest, rep *components.Report, _ *components.Ctx) error