feat(context): tambah context::shaping (port dari shortsend)
Perilaku should_shape/shape_messages tidak berubah, hanya sumber penghitungan token yang sekarang lewat context::tokens (tiktoken-rs) menggantikan heuristik char/3 bawaannya sendiri.
This commit is contained in:
@@ -28,6 +28,7 @@ pub fn count_tokens(text: &str) -> usize {
|
||||
///
|
||||
/// Return: 0 for a message with no `content` (e.g. an assistant message
|
||||
/// that only carries `tool_calls`).
|
||||
#[allow(dead_code)]
|
||||
pub fn count_message_tokens(msg: &ChatMessage) -> usize {
|
||||
msg.content.as_deref().map_or(0, count_tokens)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user