From c38b35fbad602b49750d49c679d1c9d65160b418 Mon Sep 17 00:00:00 2001 From: isaac hershenson Date: Thu, 27 Feb 2025 14:08:04 -0800 Subject: [PATCH] fix --- python/langsmith/evaluation/evaluator.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/python/langsmith/evaluation/evaluator.py b/python/langsmith/evaluation/evaluator.py index cf4347a8e..451516ff9 100644 --- a/python/langsmith/evaluation/evaluator.py +++ b/python/langsmith/evaluation/evaluator.py @@ -21,6 +21,7 @@ from typing_extensions import TypedDict +from langsmith import run_helpers as rh from langsmith import schemas try: @@ -141,9 +142,13 @@ async def aevaluate_run( self, run: Run, example: Optional[Example] = None ) -> Union[EvaluationResult, EvaluationResults]: """Evaluate an example asynchronously.""" - return await asyncio.get_running_loop().run_in_executor( - None, self.evaluate_run, run, example - ) + current_context = rh.get_tracing_context() + + def _run_with_context(): + with rh.tracing_context(**current_context): + return self.evaluate_run(run, example) + + return await asyncio.get_running_loop().run_in_executor(None, _run_with_context) _RUNNABLE_OUTPUT = Union[EvaluationResult, EvaluationResults, dict]