refactor: update event types for LLM tool usage and response
This commit is contained in:
@@ -34,7 +34,7 @@ class MainAgentHooks(BaseAgentRunHooks[AstrAgentContext]):
|
||||
):
|
||||
await call_event_hook(
|
||||
run_context.context.event,
|
||||
EventType.OnCallingFuncToolEvent,
|
||||
EventType.OnUsingLLMToolEvent,
|
||||
tool,
|
||||
tool_args,
|
||||
)
|
||||
@@ -49,7 +49,7 @@ class MainAgentHooks(BaseAgentRunHooks[AstrAgentContext]):
|
||||
run_context.context.event.clear_result()
|
||||
await call_event_hook(
|
||||
run_context.context.event,
|
||||
EventType.OnAfterCallingFuncToolEvent,
|
||||
EventType.OnLLMToolRespondEvent,
|
||||
tool,
|
||||
tool_args,
|
||||
tool_result,
|
||||
|
||||
@@ -427,7 +427,7 @@ def register_on_using_llm_tool(**kwargs):
|
||||
"""
|
||||
|
||||
def decorator(awaitable):
|
||||
_ = get_handler_or_create(awaitable, EventType.OnCallingFuncToolEvent, **kwargs)
|
||||
_ = get_handler_or_create(awaitable, EventType.OnUsingLLMToolEvent, **kwargs)
|
||||
return awaitable
|
||||
|
||||
return decorator
|
||||
@@ -453,7 +453,7 @@ def register_on_llm_tool_respond(**kwargs):
|
||||
|
||||
def decorator(awaitable):
|
||||
_ = get_handler_or_create(
|
||||
awaitable, EventType.OnAfterCallingFuncToolEvent, **kwargs
|
||||
awaitable, EventType.OnLLMToolRespondEvent, **kwargs
|
||||
)
|
||||
return awaitable
|
||||
|
||||
|
||||
@@ -189,7 +189,8 @@ class EventType(enum.Enum):
|
||||
OnLLMResponseEvent = enum.auto() # LLM 响应后
|
||||
OnDecoratingResultEvent = enum.auto() # 发送消息前
|
||||
OnCallingFuncToolEvent = enum.auto() # 调用函数工具
|
||||
OnAfterCallingFuncToolEvent = enum.auto() # 调用函数工具后
|
||||
OnUsingLLMToolEvent = enum.auto() # 使用 LLM 工具
|
||||
OnLLMToolRespondEvent = enum.auto() # 调用函数工具后
|
||||
OnAfterMessageSentEvent = enum.auto() # 发送消息后
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user