media

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package media hydrates session-relative media references into provider bytes and keeps one assembled request inside its byte budget.

It never knows a session path: the application injects a Loader that resolves a reference to verified bytes, so the ai package stays free of session layout knowledge.

Index

Constants

View Source
const Placeholder = "[image omitted: request size budget]"

Placeholder replaces an image part the request budget evicted.

Variables

View Source
var ErrRequestBudget = errors.New("coding media: request exceeds the size budget")

ErrRequestBudget means hydration and eviction could not fit the request inside the configured budget, so no provider call may be made.

Functions

This section is empty.

Types

type Hydrator

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

Hydrator fills referenced media on a copy of the session messages and evicts the oldest image parts until the request fits. The session snapshot is never mutated.

func New

func New(loader Loader, budget int) *Hydrator

New returns a hydrator over loader with a request byte budget. A nil loader or a non-positive budget disables the corresponding behavior; New returns nil when loader is nil.

func (*Hydrator) Budget

func (h *Hydrator) Budget() int

Budget returns the configured request byte budget.

func (*Hydrator) Hydrate

func (h *Hydrator) Hydrate(ctx context.Context, messages []ai.Message) ([]ai.Message, error)

Hydrate returns a copy of messages with every reference resolved and the request fitted to the budget. It is the agent transform hook: it runs once per model call and leaves the durable transcript untouched.

type Loader

type Loader interface {
	Load(ctx context.Context, path, digest string) ([]byte, error)
}

Loader resolves one session-relative media reference to verified bytes. Implementations must return an error when the file is missing or its digest does not match.

Jump to

Keyboard shortcuts

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