pub fn first_request_input(s: &EconomicsSession) -> Option<u64>Expand description
The input tokens of a session’s first request: everything the session was given before
the model had done anything (system prompt, instruction files, hook output, the prompt).
The three disjoint input fields are summed; the request’s output is not input and is
left out. None when the session made no request.
use majordomus_cli::economics::model::EconomicsSession;
use majordomus_cli::economics::usage::{anthropic_request, first_request_input};
let first = serde_json::json!({"input_tokens": 4, "cache_creation_input_tokens": 12000,
"cache_read_input_tokens": 0, "output_tokens": 300});
let second = serde_json::json!({"input_tokens": 9, "cache_read_input_tokens": 12000});
let mut s = session(vec![anthropic_request("m", &first), anthropic_request("m", &second)]);
assert_eq!(first_request_input(&s), Some(12_004), "output and later requests excluded");
s.requests.clear();
assert_eq!(first_request_input(&s), None);