Skip to content

Commit 22d978e

Browse files
committed
refactor(llm): rename _get_message_tokens to public API name
1 parent 689eb86 commit 22d978e

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

strix/llm/llm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from strix.config import Config
1212
from strix.llm.config import LLMConfig
13-
from strix.llm.memory_compressor import MemoryCompressor, _get_message_tokens
13+
from strix.llm.memory_compressor import MemoryCompressor, get_message_tokens
1414
from strix.llm.utils import (
1515
_truncate_to_first_function,
1616
fix_incomplete_tool_call,
@@ -182,7 +182,7 @@ def _prepare_messages(self, conversation_history: list[dict[str, Any]]) -> list[
182182
)
183183

184184
reserved_tokens = sum(
185-
_get_message_tokens(msg, self.config.litellm_model) for msg in messages
185+
get_message_tokens(msg, self.config.litellm_model) for msg in messages
186186
)
187187
compressed = list(
188188
self.memory_compressor.compress_history(conversation_history, reserved_tokens)

strix/llm/memory_compressor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def _count_tokens(text: str, model: str) -> int:
5252
return len(text) // 4 # Rough estimate
5353

5454

55-
def _get_message_tokens(msg: dict[str, Any], model: str) -> int:
55+
def get_message_tokens(msg: dict[str, Any], model: str) -> int:
5656
content = msg.get("content", "")
5757
if isinstance(content, str):
5858
return _count_tokens(content, model)
@@ -209,7 +209,7 @@ def compress_history(
209209
model_name: str = self.model_name # type: ignore[assignment]
210210

211211
total_tokens = reserved_tokens + sum(
212-
_get_message_tokens(msg, model_name) for msg in system_msgs + regular_msgs
212+
get_message_tokens(msg, model_name) for msg in system_msgs + regular_msgs
213213
)
214214

215215
if total_tokens <= MAX_TOTAL_TOKENS * 0.9:

0 commit comments

Comments
 (0)