test: verify sampling parameters through the full governance stack
This commit is contained in:
@@ -29,7 +29,7 @@ if TYPE_CHECKING:
|
||||
|
||||
|
||||
class TelemetryEmitter:
|
||||
"""从请求与结果组装 20 字段并写入 recorder;一切写失败降级 warning。"""
|
||||
"""从请求与结果组装 21 字段并写入 recorder;一切写失败降级 warning。"""
|
||||
|
||||
def __init__(self, recorder: TelemetryRecorder, *, pricing: PricingTable | None = None) -> None:
|
||||
self._recorder = recorder
|
||||
@@ -65,9 +65,7 @@ class TelemetryEmitter:
|
||||
cached_prompt_tokens=response.cached_prompt_tokens if response else None,
|
||||
model_reported=response.model_reported if response else None,
|
||||
# 唯一有"生效源"的入口,故是唯一能并上 extra_body 的(设计决策 D)
|
||||
sampling=canonical_sampling_json(
|
||||
merge_sampling(source.extra_body, request.sampling)
|
||||
),
|
||||
sampling=canonical_sampling_json(merge_sampling(source.extra_body, request.sampling)),
|
||||
)
|
||||
|
||||
async def emit_cache_hit(self, *, request: ChatRequest, response: LLMResponse) -> None:
|
||||
|
||||
@@ -59,9 +59,7 @@ def validate_request_overlay(overlay: Mapping[str, Any], *, origin: str) -> dict
|
||||
return dict(overlay)
|
||||
|
||||
|
||||
def merge_sampling(
|
||||
extra_body: Mapping[str, Any], sampling: Mapping[str, Any]
|
||||
) -> dict[str, Any]:
|
||||
def merge_sampling(extra_body: Mapping[str, Any], sampling: Mapping[str, Any]) -> dict[str, Any]:
|
||||
"""合并配置级与调用级采样参数;调用级优先(issue #4 设计决策 A)。"""
|
||||
return {**extra_body, **sampling}
|
||||
|
||||
@@ -237,9 +235,7 @@ class SourceConfig:
|
||||
object.__setattr__(self, "extra_body", MappingProxyType(validated))
|
||||
|
||||
|
||||
def strip_unsupported_extra_body(
|
||||
sources: list[SourceConfig], *, path: str
|
||||
) -> list[SourceConfig]:
|
||||
def strip_unsupported_extra_body(sources: list[SourceConfig], *, path: str) -> list[SourceConfig]:
|
||||
"""剥离非 chat 路径不消费的 `extra_body` 并 warning(issue #4 决策 G)。
|
||||
|
||||
剥离是必需的而非顺手清理: embedding 的 payload 硬编码 `{model, input}`、
|
||||
|
||||
Reference in New Issue
Block a user