[ PROMPT_NODE_22396 ]
adapter-system
[ SKILL_DOCUMENTATION ]
# 适配器与拦截器系统
NeMo Evaluator 使用适配器系统来处理评估引擎和模型端点之间的请求与响应。`nemo-evaluator` 核心库为常见用例提供了内置拦截器。
## 架构概览
┌───────────────────────────────────────────────────────────────┐
│ 适配器流水线 │
│ │
│ 请求 ───► [拦截器 1] ───► [拦截器 2] ───► │
│ │
│ │ │
│ ▼ │
│ ┌───────────────────────────────────┐ │
│ │ 端点拦截器 │ │
│ │ (调用模型 API 的 HTTP 请求) │ │
│ └───────────────────────────────────┘ │
│ │ │
│ ▼ │
│ 响应 ◄─── [拦截器 3] ◄─── [拦截器 4] ◄─── │
│ │
└───────────────────────────────────────────────────────────────┘
拦截器在请求时按顺序执行,在响应时按相反顺序执行。
## 配置适配器
适配器配置在 `target.api_endpoint.adapter_config` 部分指定:
yaml
target:
api_endpoint:
model_id: meta/llama-3.1-8b-instruct
url: https://integrate.api.nvidia.com/v1/chat/completions
api_key_name: NGC_API_KEY
adapter_config:
interceptors:
- name: system_message
config:
system_message: "You are a helpful assistant."
- name: caching
config:
cache_dir: "./cache"
- name: endpoint
- name: reasoning
config:
start_reasoning_token: ""
end_reasoning_token: ""
## 可用拦截器
### 系统消息拦截器
将系统提示词注入到聊天请求中。
yaml
- name: system_message
config:
system_message: "You are a helpful AI assistant. Think step by step."
**效果**: 在消息数组前添加一条系统消息。
### 请求日志拦截器
记录出站 API 请求以进行调试和分析。
yaml
- name: request_log