nemo_relay.plugin

View as Markdown

Generated from python/nemo_relay/plugin.pyi.

Module nemo_relay.plugin.

Generic plugin configuration and registration helpers.

Classes

ConfigDiagnostic(_ConfigDiagnosticRequired)

One plugin validation diagnostic.

ConfigReport(TypedDict)

Validation or activation report for a plugin config.

PluginContext(Protocol)

Component-scoped registration context passed to custom plugin handlers.

Methods

register_subscriber
1def register_subscriber(name: str, callback: Callable[[Event], None]) -> None

Register an infallible event subscriber for this component.

register_tool_sanitize_request_guardrail
1def register_tool_sanitize_request_guardrail(name: str, priority: int, callback: ToolSanitizeGuardrail) -> None

Register a tool sanitize-request guardrail for this component.

register_tool_sanitize_response_guardrail
1def register_tool_sanitize_response_guardrail(name: str, priority: int, callback: ToolSanitizeGuardrail) -> None

Register a tool sanitize-response guardrail for this component.

register_tool_conditional_execution_guardrail
1def register_tool_conditional_execution_guardrail(name: str, priority: int, callback: ToolConditionalExecutionGuardrail) -> None

Register a tool conditional-execution guardrail for this component.

register_llm_sanitize_request_guardrail
1def register_llm_sanitize_request_guardrail(name: str, priority: int, callback: LlmSanitizeRequestGuardrail) -> None

Register an LLM sanitize-request guardrail for this component.

register_llm_sanitize_response_guardrail
1def register_llm_sanitize_response_guardrail(name: str, priority: int, callback: LlmSanitizeResponseGuardrail) -> None

Register an LLM sanitize-response guardrail for this component.

register_llm_conditional_execution_guardrail
1def register_llm_conditional_execution_guardrail(name: str, priority: int, callback: LlmConditionalExecutionGuardrail) -> None

Register an LLM conditional-execution guardrail for this component.

register_llm_request_intercept
1def register_llm_request_intercept(name: str, priority: int, break_chain: bool, callback: LlmRequestIntercept) -> None

Register an LLM request intercept for this component.

register_llm_execution_intercept
1def register_llm_execution_intercept(name: str, priority: int, callback: LlmExecutionIntercept) -> None

Register an LLM execution intercept for this component.

register_llm_stream_execution_intercept
1def register_llm_stream_execution_intercept(name: str, priority: int, callback: LlmStreamExecutionIntercept) -> None

Register an LLM streaming execution intercept for this component.

register_tool_request_intercept
1def register_tool_request_intercept(name: str, priority: int, break_chain: bool, callback: ToolRequestIntercept) -> None

Register a tool request intercept for this component.

register_tool_execution_intercept
1def register_tool_execution_intercept(name: str, priority: int, callback: ToolExecutionIntercept) -> None

Register a tool execution intercept for this component.

Plugin(Protocol)

Custom plugin callback contract.

Methods

validate
1def validate(plugin_config: JsonObject) -> list[ConfigDiagnostic] | None

Validate one component-local config object.

register
1def register(plugin_config: JsonObject, context: PluginContext) -> None

Install middleware and subscribers for one component instance.

ConfigPolicy

Policy for unsupported plugin configuration.

Methods

ConfigPolicy
1def ConfigPolicy(unknown_component: UnsupportedBehavior = 'warn', unknown_field: UnsupportedBehavior = 'warn', unsupported_value: UnsupportedBehavior = 'error') -> None

Create an instance.

to_dict
1def to_dict() -> JsonObject

Serialize this policy to the canonical JSON object shape.

ComponentSpec

One top-level custom plugin component.

Methods

ComponentSpec
1def ComponentSpec(kind: str, enabled: bool = True, config: JsonObject = ...) -> None

Create an instance.

to_dict
1def to_dict() -> JsonObject

Serialize this component to the canonical JSON object shape.

PluginConfig

Canonical plugin configuration document.

Methods

PluginConfig
1def PluginConfig(version: int = 1, components: list[object] = ..., policy: ConfigPolicy = ...) -> None

Create an instance.

to_dict
1def to_dict() -> JsonObject

Serialize this config to the canonical JSON document shape.

Functions

validate

1def validate(config: PluginConfig | JsonObject) -> ConfigReport

Validate a plugin configuration without changing runtime state.

initialize

1async def initialize(config: PluginConfig | JsonObject) -> ConfigReport

Validate and activate a plugin configuration.

clear

1def clear() -> None

Clear the active plugin configuration.

plugin

1def plugin(config: PluginConfig | JsonObject) -> AsyncContextManager[ConfigReport]

Context manager for plugin initialization and cleanup.

report

1def report() -> ConfigReport | None

Return the last successful plugin report.

list_kinds

1def list_kinds() -> list[str]

List registered custom plugin kinds.

register

1def register(plugin_kind: str, plugin: Plugin) -> None

Register a custom plugin implementation.

deregister

1def deregister(plugin_kind: str) -> bool

Deregister a custom plugin kind.

Type Aliases And Constants

  • UnsupportedBehavior