module AgentRunCostRollup
Overview
Roll up the cost of AI agent runs from token counts. Prices are per one million tokens and are set by you; the tool has no price list.
Defined in:
agent_run_cost_rollup.crConstant Summary
-
REQUIRED =
["run_id", "agent", "input_tokens", "output_tokens"] of ::String -
USAGE =
"usage: agent-run-cost-rollup runs.csv --input-price P --output-price P\nCSV columns: run_id, agent, input_tokens, output_tokens. Prices are per one million tokens and are set by you (no defaults). More: https://www.onegtmlab.dev/glossary/ai-agent" -
VERSION =
"1.0.0"
Class Method Summary
-
.analyze(text : String, prices : Prices) : Report
Parse the CSV text and build the report.
-
.cli(args : Array(String), stdout : IO, stderr : IO) : Int32
Command line entry.
-
.parse_csv(text : String) : Array(Array(String))
Small CSV reader: comma separated, double quoted fields may hold commas, line breaks and "" for a quote mark.
- .render(report : Report) : String
-
.tokens(raw : String, field : String, n : Int32, id : String) : Int64
Parse a whole-number token cell.
Class Method Detail
Parse the CSV text and build the report. Raises ArgumentError on bad input. Row numbers count the header as row 1.
def self.cli(args : Array(String), stdout : IO, stderr : IO) : Int32
#
Command line entry. Returns the exit code: 0 ok, 1 bad input or file, 2 usage.
def self.parse_csv(text : String) : Array(Array(String))
#
Small CSV reader: comma separated, double quoted fields may hold commas, line breaks and "" for a quote mark. Returns rows of raw cell strings.
def self.tokens(raw : String, field : String, n : Int32, id : String) : Int64
#
Parse a whole-number token cell. Raises ArgumentError naming the row.