Count cache tokens in telemetry, budget and report (#16)
This commit was merged in pull request #16.
This commit is contained in:
1 parent
67a5bdedb9
commit
374cf28aed
7 files changed
+90
-13
No files matched your search
@@ -19,6 +19,13 @@ pub enum Status {
|
||||
NeedsHuman,
|
||||
}
|
||||
|
||||
impl Run {
|
||||
/// Everything the model processed: fresh + cached input + output.
|
||||
pub fn total_tokens(&self) -> u64 {
|
||||
self.input_tokens + self.cache_read_tokens + self.cache_write_tokens + self.output_tokens
|
||||
}
|
||||
}
|
||||
|
||||
impl Status {
|
||||
pub fn active(self) -> bool {
|
||||
matches!(self, Status::Queued | Status::Running | Status::Gating)
|
||||
@@ -45,8 +52,13 @@ pub struct Run {
|
||||
pub ended: Option<u64>,
|
||||
pub hx_exit: Option<i32>,
|
||||
pub gate_exit: Option<i32>,
|
||||
/// Fresh (uncached) input only; with the cache fields below this is everything hx sent.
|
||||
pub input_tokens: u64,
|
||||
pub output_tokens: u64,
|
||||
#[serde(default)]
|
||||
pub cache_read_tokens: u64,
|
||||
#[serde(default)]
|
||||
pub cache_write_tokens: u64,
|
||||
pub session: Option<String>,
|
||||
/// hx runs so far (1 + retries).
|
||||
#[serde(default)]
|
||||
@@ -169,6 +181,8 @@ mod tests {
|
||||
gate_exit: None,
|
||||
input_tokens: 0,
|
||||
output_tokens: 0,
|
||||
cache_read_tokens: 0,
|
||||
cache_write_tokens: 0,
|
||||
session: None,
|
||||
attempts: 0,
|
||||
turns: 0,
|
||||
|
||||
Reference in new issue
Block a user