usage

package
v0.0.0-beta Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package usage defines token usage tracking.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Usage

type Usage struct {
	// Input is the number of prompt tokens.
	Input int `json:"input"`
	// Output is the number of completion tokens.
	Output int `json:"output"`
}

Usage represents token counts for a completion.

func (*Usage) Add

func (u *Usage) Add(other Usage)

Add accumulates another Usage into this one.

func (Usage) PercentOf

func (u Usage) PercentOf(limit int) float64

PercentOf calculates token usage as a percentage of the given limit.

func (Usage) String

func (u Usage) String() string

String returns a formatted token usage summary.

func (Usage) Total

func (u Usage) Total() int

Total returns the sum of input and output tokens.

Jump to

Keyboard shortcuts

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