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

usage

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: Apache-2.0 Imports: 2 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Usage

type Usage = content.Usage

Usage is the canonical normalized token-usage domain owned by core/content.

type UsageNormalizationError

type UsageNormalizationError struct {
	Field  UsageNormalizationField
	Reason UsageNormalizationReason
	Value  int64
	Left   content.TokenCount
	Right  content.TokenCount
	// Cause is retained for source and errors.Is/As compatibility. New wire
	// normalization errors generally have no underlying cause.
	Cause error
}

UsageNormalizationError reports a usage value a codec could not normalize. Every reason here is a malformed or unrepresentable WIRE value — a null where a count was required, a fraction, a negative, an arithmetic result that does not fit. None of them is a disagreement between two well-formed counts: the relationship between ReasoningTokens and OutputTokens is a documented convention a provider may break, not a decode failure, and it is observed through content.Usage.ReasoningWithinOutput instead.

func (*UsageNormalizationError) Error

func (e *UsageNormalizationError) Error() string

func (*UsageNormalizationError) Unwrap

func (e *UsageNormalizationError) Unwrap() error

type UsageNormalizationField

type UsageNormalizationField string
const (
	UsageNormalizationFieldInputTokens         UsageNormalizationField = "InputTokens"
	UsageNormalizationFieldOutputTokens        UsageNormalizationField = "OutputTokens"
	UsageNormalizationFieldCacheReadTokens     UsageNormalizationField = "CacheReadTokens"
	UsageNormalizationFieldCacheCreationTokens UsageNormalizationField = "CacheCreationTokens"
	UsageNormalizationFieldReasoningTokens     UsageNormalizationField = "ReasoningTokens"
	UsageNormalizationFieldContextTokens       UsageNormalizationField = "ContextTokens"
	UsageNormalizationFieldTotalTokens         UsageNormalizationField = "TotalTokens"
)

type UsageNormalizationReason

type UsageNormalizationReason string
const (
	UsageNormalizationReasonNegative              UsageNormalizationReason = "negative"
	UsageNormalizationReasonComponentsExceedTotal UsageNormalizationReason = "components exceed total"
	UsageNormalizationReasonOverflow              UsageNormalizationReason = "overflow"
	// Deprecated: reasoning/output divergence is no longer a fatal decode error.
	UsageNormalizationReasonReasoningExceedsOutput UsageNormalizationReason = "reasoning exceeds output"
	UsageNormalizationReasonNull                   UsageNormalizationReason = "null"
	UsageNormalizationReasonFractional             UsageNormalizationReason = "fractional"
	UsageNormalizationReasonOutOfRange             UsageNormalizationReason = "out of range"
	UsageNormalizationReasonInvalidType            UsageNormalizationReason = "invalid type"
	UsageNormalizationReasonInvalidField           UsageNormalizationReason = "invalid field"
	UsageNormalizationReasonTotalMismatch          UsageNormalizationReason = "total mismatch"
	// Deprecated: retained for compatibility with callers classifying legacy
	// core-domain validation failures.
	UsageNormalizationReasonDomainValidation UsageNormalizationReason = "domain validation"
)

Jump to

Keyboard shortcuts

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