fix(benchmark): 记录实际Embedding空间与逐样本回退信息

This commit is contained in:
2026-09-04 07:25:12 +08:00
parent 5dd5a46aae
commit a75d81a7d9
12 changed files with 157 additions and 7 deletions
+21
View File
@@ -0,0 +1,21 @@
"""Task-local observations of the embedding path actually used by a search."""
from contextlib import contextmanager
from contextvars import ContextVar
_observation: ContextVar[dict | None] = ContextVar("embedding_observation", default=None)
@contextmanager
def capture_embedding():
result = {"source": "not_used"}
token = _observation.set(result)
try:
yield result
finally:
_observation.reset(token)
def record_embedding(**fields) -> None:
result = _observation.get()
if result is not None:
result.update(fields)