mirror of
https://github.com/dongdongunique/EvoSynth.git
synced 2026-07-15 16:47:30 +02:00
first commit
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
from ..base_dataset import BaseDataset
|
||||
from ...core.registry import dataset_registry
|
||||
from typing import Iterator, Any, List
|
||||
|
||||
@dataset_registry.register("static")
|
||||
class StaticDataset(BaseDataset):
|
||||
"""
|
||||
一个简单的静态内存数据集。
|
||||
主要用于快速测试和演示,数据直接在配置文件中定义。
|
||||
"""
|
||||
def __init__(self, prompts: List[str], **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
self.prompts = prompts
|
||||
|
||||
def __iter__(self) -> Iterator[Any]:
|
||||
return iter(self.prompts)
|
||||
|
||||
def __getitem__(self, idx):
|
||||
return self.prompts[idx]
|
||||
|
||||
def __len__(self) -> int:
|
||||
return len(self.prompts)
|
||||
|
||||
def __getitem__(self, index: int) -> Any:
|
||||
"""Support indexing for dataset access"""
|
||||
return self.prompts[index]
|
||||
Reference in New Issue
Block a user