nemo_evaluator.adapters#
Interceptors and PostEvalHooks are important part of NeMo Evaluator SDK. They expand functionality of each harness, providing a standardized way of enabling features in your evaluation runs.
Behind each interceptor and post-eval-hook stands a specific class that implements its logic.
However, these classes are referenced only to provide their configuration options which are reflected in Params of each class and to point from which classes one should inherit.
From the usage perspective, one should always use configuration classes (see Configuration) to add them to evaluations. No interceptor should be directly instantiated.
Interceptors are defined in a chain. They go under target.api_endpoint.adapter_config and can be defined as follow:
adapter_config = AdapterConfig(
interceptors=[
InterceptorConfig(
name="system_message",
enabled=True,
config={"system_message": "You are a helpful assistant."}
),
InterceptorConfig(name="request_logging", enabled=True),
InterceptorConfig(
name="caching",
enabled=True,
config={"cache_dir": "./cache", "reuse_cached_responses": True}
),
InterceptorConfig(name="reasoning", enabled=True),
InterceptorConfig(name="endpoint")
]
)
Configuration#
Configuration for discovering 3rd party modules and directories |
|
Configuration for a single interceptor |
|
Configuration for a single post-evaluation hook |
|
Adapter configuration with registry-based interceptor support |
Interceptors#
Caching interceptor is special in the sense that it intercepts both requests and responses. |
|
Required interceptor that handles the actual API communication. |
|
Adapter for modifying request payload by removing, adding, and renaming parameters |
|
Progress tracking via external webhook. |
|
Adapter for handling non-retryable client error to raise an exception instead of continuing the benchmark. |
|
Logs incoming requests. |
|
Logs responses. |
|
Processes reasoning tokens from response. |
|
Collects aggregated statistics from API responses for metrics collection. |
|
Adds or replaces system message in requests. |
PostEvalHooks#
|
Post-evaluation hook that generates reports from cached requests and responses. |
Interfaces#
Interface for providing interception of requests. |
|
Interface for providing interception of responses. |
|
Interface for interceptors that can either continue the request chain or return a response. |
|
Interface for post-evaluation hooks that run after the evaluation completes. |