跳转到内容

事件处理器

基类:EventBaseModel

基础回调处理器,可用于追踪事件的开始与结束。

workflows/handler.py 中的源代码llama_index_instrumentation/event_handlers/base.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class BaseEventHandler(BaseModel):
    """Base callback handler that can be used to track event starts and ends."""

    model_config = ConfigDict(arbitrary_types_allowed=True)

    @classmethod
    def class_name(cls) -> str:
        """Class name."""
        return "BaseEventHandler"

    @abstractmethod
    def handle(self, event: BaseEvent, **kwargs: Any) -> Any:
        """Logic for handling event."""

    async def ahandle(self, event: BaseEvent, **kwargs: Any) -> Any:
        return self.handle(event, **kwargs)

class_name classmethod #

class_name() -> str

类名。

workflows/handler.py 中的源代码llama_index_instrumentation/event_handlers/base.py
14
15
16
17
@classmethod
def class_name(cls) -> str:
    """Class name."""
    return "BaseEventHandler"

处理 abstractmethod #

handle(event: BaseEvent, **kwargs: Any) -> Any

处理事件的逻辑。

workflows/handler.py 中的源代码llama_index_instrumentation/event_handlers/base.py
19
20
21
@abstractmethod
def handle(self, event: BaseEvent, **kwargs: Any) -> Any:
    """Logic for handling event."""

选项: 显示根目录标题:是 显示根目录完整路径:否