Help us shape the future of Go! Take the 2026 Go Developer Survey

audit

package
v0.2.7 Latest Latest
Warning

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

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

Documentation

Overview

Package audit builds the LLMTurn record of each model call that led to tool calls.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SerializeMessages

func SerializeMessages(msgs []*schema.Message) (raw []byte, msgCount, charCount int32)

SerializeMessages JSON-encodes the messages sent to the model as {"messages":[...]}. Over 256 KiB the oldest messages are dropped and "truncated" is set. It returns the JSON, the number of messages kept and the character count of all messages.

func SerializeToolCalls

func SerializeToolCalls(msg *schema.Message) []byte

SerializeToolCalls JSON-encodes an assistant message's tool calls, or "[]".

Types

type CostEstimator

type CostEstimator interface {
	Estimate(provider, model string, inputTokens, outputTokens int) float64
}

CostEstimator prices one turn. → the caller's loop.CostEstimator, or defaults.ZeroCost

type ModelIdentifier

type ModelIdentifier interface {
	Identity() (provider, model string)
}

ModelIdentifier names the provider and model for each turn. It is asked once per turn, so it may change during a run. → the caller's loop.ModelIdentifier, or defaults.NoIdentity

type Recorder

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

func NewRecorder

func NewRecorder(identity ModelIdentifier, cost CostEstimator, stopLabel string) *Recorder

func (*Recorder) Record

func (r *Recorder) Record(t Turn) event.LLMTurnData

type Turn

type Turn struct {
	Index         int
	InputTokens   int
	OutputTokens  int
	Request       []*schema.Message
	Reply         *schema.Message
	DurationMs    int64
	MaxIterations int
}

Turn is what happened in one model call.

Jump to

Keyboard shortcuts

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