Skip to content

BaseMiddleware

autogen.beta.middleware.base.BaseMiddleware #

BaseMiddleware(event, context)
Source code in autogen/beta/middleware/base.py
def __init__(
    self,
    event: "BaseEvent",
    context: "Context",
) -> None:
    self.initial_event = event
    self.context = context

initial_event instance-attribute #

initial_event = event

context instance-attribute #

context = context

on_turn async #

on_turn(call_next, event, context)
Source code in autogen/beta/middleware/base.py
async def on_turn(
    self,
    call_next: AgentTurn,
    event: "BaseEvent",
    context: "Context",
) -> "ModelResponse":
    return await call_next(event, context)

on_tool_execution async #

on_tool_execution(call_next, event, context)
Source code in autogen/beta/middleware/base.py
async def on_tool_execution(
    self,
    call_next: ToolExecution,
    event: "ToolCall",
    context: "Context",
) -> ToolResultType:
    return await call_next(event, context)

on_llm_call async #

on_llm_call(call_next, events, context)
Source code in autogen/beta/middleware/base.py
async def on_llm_call(
    self,
    call_next: LLMCall,
    events: "Sequence[BaseEvent]",
    context: "Context",
) -> "ModelResponse":
    return await call_next(events, context)