forked from vllm-project/vllm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[V1] Add all_token_ids attribute to Request (vllm-project#10135)
Signed-off-by: Woosuk Kwon <[email protected]> Signed-off-by: Isotr0py <[email protected]>
- Loading branch information
1 parent
27fed1f
commit 7e24806
Showing
4 changed files
with
92 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
from typing import Generic, List, TypeVar, overload | ||
|
||
T = TypeVar("T") | ||
|
||
|
||
class ConstantList(Generic[T]): | ||
|
||
def __init__(self, x: List[T]) -> None: | ||
self._x = x | ||
|
||
def append(self, item): | ||
raise Exception("Cannot append to a constant list") | ||
|
||
def extend(self, item): | ||
raise Exception("Cannot extend a constant list") | ||
|
||
def insert(self, item): | ||
raise Exception("Cannot insert into a constant list") | ||
|
||
def pop(self, item): | ||
raise Exception("Cannot pop from a constant list") | ||
|
||
def remove(self, item): | ||
raise Exception("Cannot remove from a constant list") | ||
|
||
def clear(self): | ||
raise Exception("Cannot clear a constant list") | ||
|
||
def index(self, item): | ||
return self._x.index(item) | ||
|
||
@overload | ||
def __getitem__(self, item) -> T: | ||
... | ||
|
||
@overload | ||
def __getitem__(self, s: slice, /) -> List[T]: | ||
... | ||
|
||
def __getitem__(self, item): | ||
return self._x[item] | ||
|
||
@overload | ||
def __setitem__(self, item, value): | ||
... | ||
|
||
@overload | ||
def __setitem__(self, s: slice, value, /): | ||
... | ||
|
||
def __setitem__(self, item, value): | ||
raise Exception("Cannot set item in a constant list") | ||
|
||
def __delitem__(self, item): | ||
raise Exception("Cannot delete item from a constant list") | ||
|
||
def __iter__(self): | ||
return iter(self._x) | ||
|
||
def __contains__(self, item): | ||
return item in self._x | ||
|
||
def __len__(self): | ||
return len(self._x) |