codekingpro/portable-devtools
114k
1"""Chat loaders."""2 3from abc import ABC, abstractmethod4from collections.abc import Iterator5 6from langchain_core.chat_sessions import ChatSession7 8 9class BaseChatLoader(ABC):10 """Base class for chat loaders."""11 12 @abstractmethod13 def lazy_load(self) -> Iterator[ChatSession]:14 """Lazy load the chat sessions.15 16 Returns:17 An iterator of chat sessions.18 """19 20 def load(self) -> list[ChatSession]:21 """Eagerly load the chat sessions into memory.22 23 Returns:24 A list of chat sessions.25 """26 return list(self.lazy_load())27 