token

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoAPIKey = errors.New("ANTHROPIC_API_KEY environment variable not set")

ErrNoAPIKey is returned by NewLiveRunner when ANTHROPIC_API_KEY is not set.

Functions

func EstimateDocScoutTokens

func EstimateDocScoutTokens(i int) int

EstimateDocScoutTokens returns the estimated token cost when using DocScout tools to answer question at index i. Returns 0 for out-of-range indices.

func EstimateNaiveTokens

func EstimateNaiveTokens(i int) int

EstimateNaiveTokens returns the estimated token cost for a naive AI (no DocScout) to answer question at index i. Returns 0 for out-of-range indices.

func SavingsPct

func SavingsPct(docscout, naive int) float64

SavingsPct returns the percentage of tokens saved by using DocScout vs naive.

Types

type LiveResult

type LiveResult struct {
	Index        int
	Question     string
	DocScoutToks int
	NaiveToks    int
	SavingsPct   float64
}

LiveResult holds token measurements for a single question comparison.

type LiveRunner

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

LiveRunner measures real token usage by calling the Anthropic API.

func NewLiveRunner

func NewLiveRunner(_ context.Context) (*LiveRunner, error)

NewLiveRunner creates a LiveRunner. It reads the API key from ANTHROPIC_API_KEY and returns ErrNoAPIKey if the variable is empty. No network call is made.

func (*LiveRunner) MeasureQuestion

func (r *LiveRunner) MeasureQuestion(ctx context.Context, idx int, question, docscoutContext, naiveContext string) (LiveResult, error)

MeasureQuestion calls Claude twice — once with docscoutContext and once with naiveContext — and returns the input token counts for each. MaxTokens is intentionally limited to 100 to keep API costs low.

type QuestionEstimate

type QuestionEstimate struct {
	Index        int
	DocScoutToks int
	NaiveToks    int
	SavingsPct   float64
}

QuestionEstimate holds theoretical token estimates for one canonical question.

func AllEstimates

func AllEstimates() []QuestionEstimate

AllEstimates returns theoretical estimates for all 12 canonical questions.

Jump to

Keyboard shortcuts

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