refactor: always resolve encoding from current config

Drops the cached-instance fast path so the encoding tracks runtime
config changes like every other accessor (review feedback), and trims
the docstring back to one line.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
adavyas 2026-08-05 15:32:02 -04:00
parent 042f1c26fd
commit 4b0bb99b5f
1 changed files with 1 additions and 9 deletions

View File

@ -674,15 +674,7 @@ class EmbeddingClient:
@property
def encoding(self) -> tiktoken.Encoding:
"""Get the tiktoken encoding.
Resolved without constructing the underlying client: tiktoken needs no
API key, and token-counting callers (e.g. the document dedup tie-break)
must work in environments with no embedding credentials, such as CI for
pull requests from forks.
"""
if self._instance is not None:
return self._instance.encoding
"""Get the tiktoken encoding."""
try:
return tiktoken.encoding_for_model(self._resolve_runtime_config().model)
except KeyError: