From 9169d77cf66ea2862ce634966563a5f8a7157b2a Mon Sep 17 00:00:00 2001 From: William FH <13333726+hinthornw@users.noreply.github.com> Date: Mon, 13 Nov 2023 11:03:20 -0800 Subject: [PATCH] Update error message in evaluation runner (#13296) --- .../langchain/smith/evaluation/runner_utils.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/libs/langchain/langchain/smith/evaluation/runner_utils.py b/libs/langchain/langchain/smith/evaluation/runner_utils.py index e1b78a00f06..1e17652f396 100644 --- a/libs/langchain/langchain/smith/evaluation/runner_utils.py +++ b/libs/langchain/langchain/smith/evaluation/runner_utils.py @@ -5,6 +5,7 @@ from __future__ import annotations import functools import inspect import logging +import uuid from enum import Enum from typing import ( TYPE_CHECKING, @@ -23,6 +24,8 @@ from langsmith.client import Client from langsmith.evaluation import RunEvaluator from langsmith.run_helpers import as_runnable, is_traceable_function from langsmith.schemas import Dataset, DataType, Example +from langsmith.utils import LangSmithError +from requests import HTTPError from langchain._api import warn_deprecated from langchain.callbacks.manager import Callbacks @@ -880,11 +883,19 @@ def _prepare_eval_run( reference_dataset_id=dataset.id, project_extra={"metadata": project_metadata} if project_metadata else {}, ) - except ValueError as e: + except (HTTPError, ValueError, LangSmithError) as e: if "already exists " not in str(e): raise e + uid = uuid.uuid4() + example_msg = f""" +run_on_dataset( + ... + project_name="{project_name} - {uid}", # Update since {project_name} already exists +) +""" raise ValueError( - f"Project {project_name} already exists. Please use a different name." + f"Test project {project_name} already exists. Please use a different name:" + f"\n\n{example_msg}" ) print( f"View the evaluation results for project '{project_name}'"