|
1 | 1 | mod bindings; |
2 | 2 |
|
| 3 | +use crate::core::{CL100K_BASE_PATTERN, LLAMA3_PATTERN, O200K_BASE_PATTERN}; |
3 | 4 | pub use bindings::{ |
4 | 5 | PyByteLevelStreamingDecoder, PyCL100KAgentTokens, PyDeepSeekV3AgentTokens, PyLlama3AgentTokens, |
5 | 6 | PyO200KAgentTokens, PyStreamingDecoder, PyTokenizer, |
6 | 7 | }; |
| 8 | + |
| 9 | +use pyo3::prelude::*; |
| 10 | + |
| 11 | +/// Splintr - Fast Rust BPE tokenizer with Python bindings |
| 12 | +/// |
| 13 | +/// A high-performance tokenizer featuring: |
| 14 | +/// - Regexr with JIT and SIMD (default, pure Rust) |
| 15 | +/// - Optional PCRE2 with JIT (requires `pcre2` feature) |
| 16 | +/// - Rayon parallelism for multi-core encoding |
| 17 | +/// - Linked-list BPE algorithm (avoids O(N²) on pathological inputs) |
| 18 | +/// - FxHashMap for fast lookups |
| 19 | +/// - Aho-Corasick for fast special token matching |
| 20 | +/// - LRU cache for frequently encoded chunks |
| 21 | +/// - UTF-8 streaming decoder for LLM output |
| 22 | +/// - Agent tokens for chat/reasoning/tool-use applications |
| 23 | +#[pymodule] |
| 24 | +fn _core(m: &Bound<'_, PyModule>) -> PyResult<()> { |
| 25 | + m.add_class::<PyTokenizer>()?; |
| 26 | + m.add_class::<PyStreamingDecoder>()?; |
| 27 | + m.add_class::<PyByteLevelStreamingDecoder>()?; |
| 28 | + m.add_class::<PyCL100KAgentTokens>()?; |
| 29 | + m.add_class::<PyO200KAgentTokens>()?; |
| 30 | + m.add_class::<PyLlama3AgentTokens>()?; |
| 31 | + m.add_class::<PyDeepSeekV3AgentTokens>()?; |
| 32 | + m.add("CL100K_BASE_PATTERN", CL100K_BASE_PATTERN)?; |
| 33 | + m.add("O200K_BASE_PATTERN", O200K_BASE_PATTERN)?; |
| 34 | + m.add("LLAMA3_PATTERN", LLAMA3_PATTERN)?; |
| 35 | + Ok(()) |
| 36 | +} |
0 commit comments