Skip to content

Commit 84b14bb

Browse files
committed
chore: update allowed unresolved imports and modify prefix encoding
- Added "datrie.**" to the allowed unresolved imports in pyproject.toml. - Changed the encoding method in LRUTrieCache from "latin-1" to "hex" for improved token representation.
1 parent 568dedc commit 84b14bb

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ unused-ignore-comment = "ignore"
127127
allowed-unresolved-imports = [
128128
# tinker deps
129129
"tinker.**",
130+
"datrie.**",
130131
# backend deps
131132
"accelerate.**",
132133
"awscli.**",

src/art/tinker/prefix_cache.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
import datrie
99

10-
_TOKEN_BYTES = 4
11-
_TRIE_ALPHABET = "".join(chr(i) for i in range(256))
10+
_TRIE_ALPHABET = "0123456789abcdef"
1211

1312

1413
@dataclass(frozen=True)
@@ -32,7 +31,7 @@ def _encode_tokens(tokens: Sequence[int]) -> str:
3231
packed = bytearray()
3332
for token in tokens:
3433
packed.extend(struct.pack(">I", token))
35-
return packed.decode("latin-1")
34+
return packed.hex()
3635

3736
def lookup(self, rendered_tokens: Sequence[int]) -> PrefixEntry | None:
3837
key = self._encode_tokens(rendered_tokens)

0 commit comments

Comments
 (0)