cost

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package cost provides cost tracking, optimisation, and display for the hawk engine. See ../REFACTOR_PLAN.md.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatCostDisplay

func FormatCostDisplay(totalUSD float64) string

func LoadCostHistory

func LoadCostHistory() ([]analytics.CostEntry, error)

func ModelPricing

func ModelPricing(modelName string) (inputPricePerM, outputPricePerM float64)

Types

type Cost

type Cost struct {
	Model            string
	PromptTokens     int
	CompletionTokens int
	CacheReadTokens  int
	CacheWriteTokens int
	TotalCostUSD     float64
	// contains filtered or unexported fields
}

func (*Cost) Add

func (c *Cost) Add(prompt, completion int)

func (*Cost) AddCacheTokens

func (c *Cost) AddCacheTokens(read, write int)

func (*Cost) Summary

func (c *Cost) Summary() string

func (*Cost) Total

func (c *Cost) Total() float64

func (*Cost) TotalUSD

func (c *Cost) TotalUSD() float64

type CostOptimizer

type CostOptimizer struct {
	History         []RequestCost
	Recommendations []Recommendation
	ModelPricing    map[string]ModelPrice
	// contains filtered or unexported fields
}

func NewCostOptimizer

func NewCostOptimizer() *CostOptimizer

func (*CostOptimizer) Analyze

func (co *CostOptimizer) Analyze() []Recommendation

func (*CostOptimizer) CostByModel

func (co *CostOptimizer) CostByModel() map[string]float64

func (*CostOptimizer) CostByTaskType

func (co *CostOptimizer) CostByTaskType() map[string]float64

func (*CostOptimizer) DailyCost

func (co *CostOptimizer) DailyCost() float64

func (*CostOptimizer) FormatReport

func (co *CostOptimizer) FormatReport() string

func (*CostOptimizer) ProjectSavings

func (co *CostOptimizer) ProjectSavings(recommendations []Recommendation) float64

func (*CostOptimizer) Record

func (co *CostOptimizer) Record(cost RequestCost)

func (*CostOptimizer) WeeklyCost

func (co *CostOptimizer) WeeklyCost() float64

func (*CostOptimizer) WhatIf

func (co *CostOptimizer) WhatIf(model string) float64

type CostTracker

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

func NewCostTracker

func NewCostTracker(sessionID string) *CostTracker

func (*CostTracker) Entries

func (ct *CostTracker) Entries() []analytics.CostEntry

func (*CostTracker) Record

func (ct *CostTracker) Record(entry analytics.CostEntry) error

func (*CostTracker) SessionTotal

func (ct *CostTracker) SessionTotal() float64

type ModelPrice

type ModelPrice struct {
	InputPerMillion      float64
	OutputPerMillion     float64
	CacheReadPerMillion  float64
	CacheWritePerMillion float64
}

type Recommendation

type Recommendation struct {
	Type             string
	Description      string
	EstimatedSavings float64
	Priority         string
	Action           string
}

type RequestCost

type RequestCost struct {
	Model        string
	Provider     string
	InputTokens  int
	OutputTokens int
	CostUSD      float64
	TaskType     string
	Duration     time.Duration
	CacheHit     bool
	Timestamp    time.Time
}

Jump to

Keyboard shortcuts

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