Spaces:
Sleeping
Sleeping
File size: 1,490 Bytes
2814685 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# coding: utf-8
# Copyright (c) 2025 inclusionAI.
import abc
from typing import AsyncGenerator
from aworld.core.context.base import Context, AgentContext
from aworld.core.event.base import Message
class HookPoint:
START = "start"
FINISHED = "finished"
ERROR = "error"
PRE_LLM_CALL = "pre_llm_call"
POST_LLM_CALL = "post_llm_call"
class Hook:
"""Runner hook."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def point(self):
"""Hook point."""
@abc.abstractmethod
async def exec(self, message: Message, context: Context = None) -> Message:
"""Execute hook function."""
class StartHook(Hook):
"""Process in the hook point of the start."""
__metaclass__ = abc.ABCMeta
def point(self):
return HookPoint.START
class FinishedHook(Hook):
"""Process in the hook point of the finished."""
__metaclass__ = abc.ABCMeta
def point(self):
return HookPoint.FINISHED
class ErrorHook(Hook):
"""Process in the hook point of the error."""
__metaclass__ = abc.ABCMeta
def point(self):
return HookPoint.ERROR
class PreLLMCallHook(Hook):
"""Process in the hook point of the pre_llm_call."""
__metaclass__ = abc.ABCMeta
def point(self):
return HookPoint.PRE_LLM_CALL
class PostLLMCallHook(Hook):
"""Process in the hook point of the post_llm_call."""
__metaclass__ = abc.ABCMeta
def point(self):
return HookPoint.POST_LLM_CALL
|