Skip to content

Add tokenutil alias backend support#1

Merged
JustAGhosT merged 2 commits into
mainfrom
phase-4-tokenutil
May 11, 2026
Merged

Add tokenutil alias backend support#1
JustAGhosT merged 2 commits into
mainfrom
phase-4-tokenutil

Conversation

@JustAGhosT
Copy link
Copy Markdown
Contributor

Summary

  • map Sluice policy aliases to cl100k_base token counting
  • add optional SentencePiece backend stub for Gemini-family models
  • tighten alias coverage tests

Validation

  • pytest tests/ -v
  • mypy src/tokenutil

@blocksorg
Copy link
Copy Markdown

blocksorg Bot commented May 11, 2026

Mention Blocks like a regular teammate with your question or request:

@blocks review this pull request
@blocks make the following changes ...
@blocks create an issue from what was mentioned in the following comment ...
@blocks explain the following code ...
@blocks are there any security or performance concerns?

Run @blocks /help for more information.

Workspace settings | Disable this message

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 51bd0cd5-a501-462b-9a53-9edb20e0e463

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch phase-4-tokenutil

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 35a41e4223

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/tokenutil/_sentencepiece.py Outdated
)
raise ImportError("TOKENUTIL_SENTENCEPIECE_MODEL is not set")

processor = spm.SentencePieceProcessor(model_file=model_path)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Convert model-load errors into fallbackable ImportError

If TOKENUTIL_SENTENCEPIECE_MODEL is set to an invalid/missing file, SentencePieceProcessor(model_file=...) raises a non-ImportError exception (commonly OSError), which is not caught here. Because count_tokens_for_text only falls back on ImportError, Gemini token counting will raise instead of using the heuristic path, turning a recoverable misconfiguration into a runtime failure.

Useful? React with 👍 / 👎.

@JustAGhosT JustAGhosT merged commit b9bb9ad into main May 11, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant