Skip to main content

evaluate_with

Function evaluate_with 

Source
pub fn evaluate_with<F: Fn(&str) -> usize>(
    program: &Program,
    count: F,
) -> AgentCost
Expand description

Evaluate a program with a custom token counter — any Fn(&str) -> usize, such as a host application’s exact tokenizer or a model not in Model. This lets the crate’s cost model work with any tokenizer, not just the built-in set.

use agentic_eval::tokens::{evaluate_with, Program};
// A trivial whitespace counter standing in for a real tokenizer.
let words = |s: &str| s.split_whitespace().count();
let cost = evaluate_with(&Program::new("p", "read a file"), words);
assert_eq!(cost.input, 3);