module Riffer::Rig::Commands::Cost
Constants
- LABEL_WIDTH
- NO_TURN_USAGE
- NO_USAGE
Public Instance Methods
Source
# File lib/riffer/rig/commands/cost.rb, line 11 def command Riffer::Rig::Command.new( 'cost', description: "Show the session's token usage and cost, turn by turn", extension: :core ) { |ctx| run(ctx) } end
@rbs return: Riffer::Rig::Command
(Riffer::Rig::Command::Context ctx) → void
Source
# File lib/riffer/rig/commands/cost.rb, line 21 def run(ctx) session = ctx.runtime.tally return ctx.say(NO_USAGE) unless session breakdown = turns(ctx.runtime.agent.session.messages).each_with_index.map do |turn, index| line("turn #{index + 1}", Riffer::Rig::Runtime::Usage.sum(turn)) end ctx.say([line('session', session), *breakdown].join("\n")) end
@rbs ctx: Riffer::Rig::Command::Context @rbs return: void