1
1
from collections .abc import Sequence
2
- from typing import Generic , Optional , TypeVar , Union
2
+ from typing import Generic , Optional , TypeVar
3
3
4
4
from pydantic import Field
5
5
10
10
11
11
class Item (StandardBaseModel , Generic [PromptT ]):
12
12
"""
13
- Represents a single item in a dataset, containing a prompt and its associated metadata.
13
+ Represents a single item in a dataset,
14
+ containing a prompt and its associated metadata.
14
15
"""
15
16
16
17
value : PromptT = Field (
@@ -33,11 +34,13 @@ class ItemList(Sequence[Item[PromptT]]):
33
34
Represents a list of items, each containing a prompt and its metadata.
34
35
"""
35
36
37
+ shared_prefix : Optional [PromptT ]
38
+
36
39
def __init__ (self , * items : Item [PromptT ], shared_prefix : Optional [PromptT ] = None ):
37
- self .shared_prefix : Optional [ PromptT ] = shared_prefix
38
- self ._items : list [ Item [ PromptT ]] = list (items )
40
+ self .shared_prefix = shared_prefix
41
+ self ._items = list (items )
39
42
40
- def __getitem__ (self , key ) -> Union [ Item [ PromptT ], Sequence [ Item [ PromptT ]]] :
43
+ def __getitem__ (self , key ):
41
44
return self ._items [key ]
42
45
43
46
def __len__ (self ) -> int :
0 commit comments