mirror of
https://github.com/katanemo/plano.git
synced 2026-06-29 15:49:40 +02:00
trim conversation if it exceed max limit of what router model can handle
This commit is contained in:
parent
79cbcb5fe1
commit
d1542b988a
7 changed files with 313 additions and 84 deletions
|
|
@ -1,5 +1,18 @@
|
|||
use log::debug;
|
||||
|
||||
pub trait Tokenizer {
|
||||
/// Returns the number of tokens in the given text.
|
||||
fn token_count(&self, text: &str, model_name: &str) -> Result<usize, String>;
|
||||
}
|
||||
|
||||
pub struct TiktokenTokenizer {}
|
||||
|
||||
impl Tokenizer for TiktokenTokenizer {
|
||||
fn token_count(&self, text: &str, model_name: &str) -> Result<usize, String> {
|
||||
token_count(model_name, text)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn token_count(model_name: &str, text: &str) -> Result<usize, String> {
|
||||
debug!("getting token count model={}", model_name);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue