generated from coulomb/repo-seed
feat: initial llm-connect package scaffold
Copy markitect.llm module into standalone llm_connect package. All markitect.* imports replaced with llm_connect.* equivalents. LLMError base class inlined (no markitect.exceptions dependency). Verified: from llm_connect import create_adapter works. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
16
llm_connect/_token_estimator.py
Normal file
16
llm_connect/_token_estimator.py
Normal file
@@ -0,0 +1,16 @@
|
||||
"""
|
||||
Rough token estimation for backends that don't return usage data.
|
||||
|
||||
Uses the ~4 characters per token heuristic common across English LLM tokenizers.
|
||||
"""
|
||||
|
||||
|
||||
def estimate_tokens(text: str) -> int:
|
||||
"""Estimate the number of tokens in *text*.
|
||||
|
||||
This is intentionally coarse — it is only used by the Claude Code CLI
|
||||
adapter where real token counts are unavailable.
|
||||
"""
|
||||
if not text:
|
||||
return 0
|
||||
return max(1, len(text) // 4)
|
||||
Reference in New Issue
Block a user