Skip to content

Commit a35e3f2

Browse files
authored
Update llama_cache.py
1 parent a5f16dc commit a35e3f2

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

llama_cpp/llama_cache.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import sys
22
from abc import ABC, abstractmethod
33
from collections import OrderedDict
4-
from collections.abc import Sequence
54
from typing import (
65
Optional,
6+
Sequence,
77
Tuple,
88
)
99

@@ -27,8 +27,8 @@ def cache_size(self) -> int:
2727

2828
def _find_longest_prefix_key(
2929
self,
30-
key: tuple[int, ...],
31-
) -> tuple[int, ...] | None:
30+
key: Tuple[int, ...],
31+
) -> Optional[Tuple[int, ...]]:
3232
pass
3333

3434
@abstractmethod
@@ -52,7 +52,7 @@ class LlamaRAMCache(BaseLlamaCache):
5252
def __init__(self, capacity_bytes: int = (2 << 30)):
5353
super().__init__(capacity_bytes)
5454
self.capacity_bytes = capacity_bytes
55-
self.cache_state: OrderedDict[tuple[int, ...], llama_cpp.llama.LlamaState] = (
55+
self.cache_state: OrderedDict[Tuple[int, ...], llama_cpp.llama.LlamaState] = (
5656
OrderedDict()
5757
)
5858

@@ -62,8 +62,8 @@ def cache_size(self):
6262

6363
def _find_longest_prefix_key(
6464
self,
65-
key: tuple[int, ...],
66-
) -> tuple[int, ...] | None:
65+
key: Tuple[int, ...],
66+
) -> Optional[Tuple[int, ...]]:
6767
min_len = 0
6868
min_key = None
6969
keys = (
@@ -116,10 +116,10 @@ def cache_size(self):
116116

117117
def _find_longest_prefix_key(
118118
self,
119-
key: tuple[int, ...],
120-
) -> tuple[int, ...] | None:
119+
key: Tuple[int, ...],
120+
) -> Optional[Tuple[int, ...]]:
121121
min_len = 0
122-
min_key: tuple[int, ...] | None = None
122+
min_key: Optional[Tuple[int, ...]] = None
123123
for k in self.cache.iterkeys(): # type: ignore
124124
prefix_len = llama_cpp.llama.Llama.longest_token_prefix(k, key)
125125
if prefix_len > min_len:

0 commit comments

Comments
 (0)