feat: strip extra_body on the embedding and OCR paths with a warning

Stripping is load-bearing, not tidying: those transports never send the
value, so leaving it would make telemetry record a parameter never sent.
This commit is contained in:
2026-07-31 21:36:50 -04:00
parent 4516761dbe
commit a5ebf72f17
5 changed files with 112 additions and 3 deletions
+4 -1
View File
@@ -44,6 +44,7 @@ from polygateway.types import (
OcrLayoutResult,
OcrTextResult,
Usage,
strip_unsupported_extra_body,
)
if TYPE_CHECKING:
@@ -113,7 +114,9 @@ class OcrClient:
if quota_full not in ("wait", "fail_fast"):
raise ValueError(f"quota_full 必须是 wait|fail_fast: {quota_full!r}")
self._scope = scope
self._sources = list(sources)
# MonkeyOCR 只发 multipart 表单,带 extra_body 的源必须先剥离,否则
# 遥测会记录一个从未发出的采样参数(issue #4 决策 G)
self._sources = strip_unsupported_extra_body(list(sources), path="OCR")
self._selector = selector
self._feed_health = isinstance(selector, OutcomeAwareSelector)
self._quota = QuotaGate(limiter)