nemo_evaluator.adapters.decorators
#
Decorators for registering interceptors and post-evaluation hooks with automatic interface detection.
Module Contents#
Functions#
Decorator to register interceptors or post-evaluation hooks with automatic interface detection. |
API#
- nemo_evaluator.adapters.decorators.register_for_adapter(name: str, description: str)#
Decorator to register interceptors or post-evaluation hooks with automatic interface detection.
Args: name: Unique name for the adapter component description: Human-readable description of what the component does
Example: from pydantic import BaseModel, Field
@register_for_adapter( name="my_interceptor", description="My custom request processing logic" ) class MyInterceptor(RequestInterceptor): class Params(BaseModel): api_key: str = Field(..., description="API key for authentication") timeout: int = Field(default=30, description="Request timeout in seconds") def __init__(self, params: Params): self.api_key = params.api_key self.timeout = params.timeout def intercept_request(self, ar: AdapterRequest) -> AdapterRequest: # Custom logic here return ar @register_for_adapter( name="my_hook", description="My custom post-evaluation hook" ) class MyHook(PostEvalHook): class Params(BaseModel): output_path: str = Field(..., description="Output path") def __init__(self, params: Params): self.output_path = params.output_path def post_eval_hook(self, context: AdapterGlobalContext) -> None: # Custom logic here pass