Configuration#
Configure the adapter system using the AdapterConfig
class from nemo_evaluator.adapters.adapter_config
. This class uses a registry-based interceptor architecture where you configure a list of interceptors, each with their own parameters.
Core Configuration Structure#
AdapterConfig
accepts the following structure:
from nemo_evaluator.adapters.adapter_config import AdapterConfig, InterceptorConfig
adapter_config = AdapterConfig(
interceptors=[
InterceptorConfig(
name="interceptor_name",
enabled=True, # Optional, defaults to True
config={
# Interceptor-specific parameters
}
)
],
endpoint_type="chat" # Optional, defaults to "chat"
)
Available Interceptors#
System Message Interceptor#
Name: system_message
Adds a system message to requests by adding it as a system role message.
Parameter |
Type |
Default |
Description |
---|---|---|---|
|
|
Required |
System message to add to requests |
Example:
InterceptorConfig(
name="system_message",
config={
"system_message": "You are a helpful assistant."
}
)
Reasoning Interceptor#
Name: reasoning
Processes reasoning content in responses by detecting and removing reasoning tokens, tracking reasoning statistics, and optionally extracting reasoning to separate fields.
Parameter |
Type |
Default |
Description |
---|---|---|---|
|
|
|
Token marking start of reasoning section |
|
|
|
Token marking end of reasoning section |
|
|
|
Whether to add reasoning information |
|
|
|
Migrate reasoning_content to content field with tokens |
|
|
|
Enable reasoning tracking and logging |
|
|
|
Include reasoning if end token not found |
|
|
|
Cache individual request reasoning statistics |
|
|
|
Cache directory for reasoning stats |
|
|
|
Save stats to file every N responses (None = only save via post_eval_hook) |
|
|
|
Log aggregated stats every N responses |
Example:
InterceptorConfig(
name="reasoning",
config={
"start_reasoning_token": "<think>",
"end_reasoning_token": "</think>",
"enable_reasoning_tracking": True
}
)
Request Logging Interceptor#
Name: request_logging
Logs incoming requests with configurable limits and detail levels.
Parameter |
Type |
Default |
Description |
---|---|---|---|
|
|
|
Whether to log request body |
|
|
|
Whether to log request headers |
|
|
|
Maximum requests to log (None for unlimited) |
Example:
InterceptorConfig(
name="request_logging",
config={
"max_requests": 50,
"log_request_body": True
}
)
Response Logging Interceptor#
Name: response_logging
Logs outgoing responses with configurable limits and detail levels.
Parameter |
Type |
Default |
Description |
---|---|---|---|
|
|
|
Whether to log response body |
|
|
|
Whether to log response headers |
|
|
|
Maximum responses to log (None for unlimited) |
Example:
InterceptorConfig(
name="response_logging",
config={
"max_responses": 50,
"log_response_body": True
}
)
Caching Interceptor#
Name: caching
Caches requests and responses to disk with options for reusing cached responses.
Parameter |
Type |
Default |
Description |
---|---|---|---|
|
|
|
Directory to store cache files |
|
|
|
Whether to reuse cached responses |
|
|
|
Whether to save requests to cache |
|
|
|
Whether to save responses to cache |
|
|
|
Maximum requests to save (None for unlimited) |
|
|
|
Maximum responses to save (None for unlimited) |
Notes:
If
reuse_cached_responses
isTrue
,save_responses
is automatically set toTrue
andmax_saved_responses
toNone
The system generates cache keys automatically using SHA256 hash of request data
Example:
InterceptorConfig(
name="caching",
config={
"cache_dir": "./evaluation_cache",
"reuse_cached_responses": True
}
)
Progress Tracking Interceptor#
Name: progress_tracking
Tracks evaluation progress by counting processed samples and optionally sending updates to a webhook.
Parameter |
Type |
Default |
Description |
---|---|---|---|
|
|
|
URL to post progress updates. Supports shell variable expansion. |
|
|
|
Update every N samples |
|
|
|
HTTP method for progress updates |
|
|
|
Directory to save progress file (creates a |
Example:
InterceptorConfig(
name="progress_tracking",
config={
"progress_tracking_url": "http://monitor:8000/progress",
"progress_tracking_interval": 10
}
)
Endpoint Interceptor#
Name: endpoint
Makes the actual HTTP request to the upstream API. This interceptor has no configurable parameters and is typically added automatically as the final interceptor in the chain.
Example:
InterceptorConfig(name="endpoint")
Configuration Examples#
Basic Configuration#
from nemo_evaluator.adapters.adapter_config import AdapterConfig, InterceptorConfig
adapter_config = AdapterConfig(
interceptors=[
InterceptorConfig(
name="request_logging",
config={"max_requests": 10}
),
InterceptorConfig(
name="caching",
config={"cache_dir": "./cache"}
)
]
)
Advanced Configuration#
from nemo_evaluator.adapters.adapter_config import AdapterConfig, InterceptorConfig
adapter_config = AdapterConfig(
interceptors=[
# System prompting
InterceptorConfig(
name="system_message",
config={
"system_message": "You are an expert AI assistant."
}
),
# Reasoning processing
InterceptorConfig(
name="reasoning",
config={
"start_reasoning_token": "<think>",
"end_reasoning_token": "</think>",
"enable_reasoning_tracking": True
}
),
# Request logging
InterceptorConfig(
name="request_logging",
config={
"max_requests": 1000,
"log_request_body": True
}
),
# Response logging
InterceptorConfig(
name="response_logging",
config={
"max_responses": 1000,
"log_response_body": True
}
),
# Caching
InterceptorConfig(
name="caching",
config={
"cache_dir": "./production_cache",
"reuse_cached_responses": True
}
),
# Progress tracking
InterceptorConfig(
name="progress_tracking",
config={
"progress_tracking_url": "http://monitoring:3828/progress",
"progress_tracking_interval": 10
}
)
],
endpoint_type="chat"
)
YAML Configuration#
You can also configure adapters through YAML files in your evaluation configuration:
target:
api_endpoint:
url: http://localhost:8080/v1/chat/completions
type: chat
model_id: megatron_model
adapter_config:
interceptors:
- name: system_message
config:
system_message: "You are a helpful assistant."
- name: reasoning
config:
start_reasoning_token: "<think>"
end_reasoning_token: "</think>"
- name: request_logging
config:
max_requests: 50
- name: response_logging
config:
max_responses: 50
- name: caching
config:
cache_dir: ./cache
reuse_cached_responses: true
Interceptor Order#
Interceptors are executed in the order they appear in the interceptors
list:
Request interceptors process the request in list order
The endpoint interceptor makes the actual API call (automatically added if not present)
Response interceptors process the response in reverse list order
For example, with interceptors [system_message, request_logging, caching, response_logging, reasoning]
:
Request flow:
system_message
→request_logging
→caching
(check cache) → API call (if cache miss)Response flow: API call →
caching
(save to cache) →response_logging
→reasoning
Shorthand Syntax#
You can use string names as shorthand for interceptors with default configuration:
adapter_config = AdapterConfig(
interceptors=["request_logging", "caching", "response_logging"]
)
This is equivalent to:
adapter_config = AdapterConfig(
interceptors=[
InterceptorConfig(name="request_logging"),
InterceptorConfig(name="caching"),
InterceptorConfig(name="response_logging")
]
)