port ai crate to ai2, with all tests passing

This commit is contained in:
KCaverly 2023-10-30 14:40:31 -04:00
parent 204aba07f6
commit 04ab68502b
22 changed files with 1930 additions and 0 deletions

16
crates/ai2/src/models.rs Normal file
View file

@ -0,0 +1,16 @@
pub enum TruncationDirection {
Start,
End,
}
pub trait LanguageModel {
fn name(&self) -> String;
fn count_tokens(&self, content: &str) -> anyhow::Result<usize>;
fn truncate(
&self,
content: &str,
length: usize,
direction: TruncationDirection,
) -> anyhow::Result<String>;
fn capacity(&self) -> anyhow::Result<usize>;
}