Share via


BaseAIPlugin Class

Base implementation of AIPlugin with no-op methods.

Provides default implementations for all plugin hooks that return the original values unchanged. Extend this class and override only the hooks you need to customize.

Initialize base plugin with a name.

Constructor

BaseAIPlugin(name: str)

Parameters

Name Description
name
Required

Unique identifier for this plugin

Methods

on_after_function_call

Called after a function is executed.

on_after_send

Modify response after receiving from model.

on_before_function_call

Called before a function is executed.

on_before_send

Modify input before sending to model.

on_build_functions

Modify the functions array passed to the model.

on_build_instructions

Modify the system message before sending to model.

on_after_function_call

Called after a function is executed.

async on_after_function_call(function_name: str, result: str, args: BaseModel | None = None) -> str | None

Parameters

Name Description
function_name
Required
result
Required
args
Default value: None

on_after_send

Modify response after receiving from model.

async on_after_send(response: ModelMessage) -> ModelMessage | None

Parameters

Name Description
response
Required

on_before_function_call

Called before a function is executed.

async on_before_function_call(function_name: str, args: BaseModel | None = None) -> None

Parameters

Name Description
function_name
Required
args
Default value: None

on_before_send

Modify input before sending to model.

async on_before_send(input: UserMessage | ModelMessage | SystemMessage | FunctionMessage) -> UserMessage | ModelMessage | SystemMessage | FunctionMessage | None

Parameters

Name Description
input
Required

on_build_functions

Modify the functions array passed to the model.

async on_build_functions(functions: list[microsoft.teams.ai.function.Function[pydantic.main.BaseModel]]) -> list[microsoft.teams.ai.function.Function[pydantic.main.BaseModel]] | None

Parameters

Name Description
functions
Required

on_build_instructions

Modify the system message before sending to model.

async on_build_instructions(instructions: SystemMessage | None) -> SystemMessage | None

Parameters

Name Description
instructions
Required

Attributes

name

Unique name of the plugin.

Returns

Type Description

String identifier for this plugin