diff --git a/python/langsmith/evaluation/_runner.py b/python/langsmith/evaluation/_runner.py index 4742a99b9..45478ad2d 100644 --- a/python/langsmith/evaluation/_runner.py +++ b/python/langsmith/evaluation/_runner.py @@ -112,7 +112,7 @@ def evaluate( Defaults to None. description (Optional[str]): A free-form text description for the experiment. max_concurrency (Optional[int]): The maximum number of concurrent - evaluations to run. Defaults to None. + evaluations to run. Defaults to None (max number of workers). client (Optional[langsmith.Client]): The LangSmith client to use. Defaults to None. blocking (bool): Whether to block until the evaluation is complete. @@ -371,16 +371,19 @@ class ExperimentResults: wait() -> None: Waits for the experiment data to be processed. """ - def __init__( - self, - experiment_manager: _ExperimentManager, - ): + def __init__(self, experiment_manager: _ExperimentManager, blocking: bool = True): self._manager = experiment_manager self._results: List[ExperimentResultRow] = [] self._queue: queue.Queue[ExperimentResultRow] = queue.Queue() self._processing_complete = threading.Event() - self._thread = threading.Thread(target=self._process_data) - self._thread.start() + if not blocking: + self._thread: Optional[threading.Thread] = threading.Thread( + target=self._process_data + ) + self._thread.start() + else: + self._thread = None + self._process_data() @property def experiment_name(self) -> str: @@ -426,7 +429,8 @@ def wait(self) -> None: This method blocks the current thread until the evaluation runner has finished its execution. """ - self._thread.join() + if self._thread: + self._thread.join() ## Public API for Comparison Experiments @@ -878,10 +882,7 @@ def _evaluate( # Apply the experiment-level summary evaluators. manager = manager.with_summary_evaluators(summary_evaluators) # Start consuming the results. - results = ExperimentResults(manager) - if blocking: - # Wait for the evaluation to complete. - results.wait() + results = ExperimentResults(manager, blocking=blocking) return results diff --git a/python/pyproject.toml b/python/pyproject.toml index f860e587b..171473bbd 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "langsmith" -version = "0.1.114" +version = "0.1.115" description = "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform." authors = ["LangChain "] license = "MIT"