Skip to content

Conversation

@jsibbison-square
Copy link
Contributor

Adds cost to session.log. We can update the format later just getting the data piped through.

{"session_file":"~/.config/goose/sessions/yoyqaq3e.jsonl","usage":[{"model":"claude-3-5-sonnet-20241022-v2:0","usage":{"input_tokens":2067,"output_tokens":204,"total_tokens":2271},"cost":"0.009261"}]}
{"session_file":"~/.config/goose/sessions/hao4empo.jsonl","usage":[{"model":"gpt-4o-2024-08-06","usage":{"input_tokens":2749,"output_tokens":41,"total_tokens":2790},"cost":"0.0072825"}]}

Changes

Adds costs for models.

Instead of providers collecting usage and the agent asking for it, the provider returns usage (as it already did) to the agent along with the cost on each 'complete' call. The agent collects all usages (which now includes cost). This keeps providers with less state and also makes it trivial for the agent to collect usage from different providers/models if we ever head back down that path.

pub struct ProviderUsage {
    pub model: String,
    pub usage: Usage,
    pub cost: Option<Decimal>,
}

use super::base::{Pricing, Usage};

lazy_static::lazy_static! {
static ref MODEL_PRICING: HashMap<String, Pricing> = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this overlaps with ModelConfig in the #466 a bit. Might be worthwhile to merge them

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will get them both merged and look for opportunities.

* v1.0:
  chore: don't require UV to download tokenizers (#473)
@jsibbison-square jsibbison-square merged commit 6c48632 into v1.0 Dec 16, 2024
3 checks passed
lifeizhou-ap added a commit that referenced this pull request Dec 17, 2024
* v1.0:
  Restore command history when resuming session (#483)
  Newline in cli (#485)
  remove cliclack prompt (#484)
  feat:model-specific-configuration (#466)
  Adds session cost to goose.log (#474)
@yingjiehe-xyz yingjiehe-xyz deleted the jsibbison-20241216-session-cost branch February 5, 2025 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants