[Evals] Support list examples by dataset version tag (#18534)

previously only supported by timestamp
This commit is contained in:
William FH 2024-03-04 14:23:32 -08:00 committed by GitHub
parent 72ae744588
commit 30ccc009e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 14 deletions

View File

@ -979,20 +979,15 @@ def _prepare_eval_run(
) -> Tuple[MCF, TracerSession, Dataset, List[Example]]:
wrapped_model = _wrap_in_chain_factory(llm_or_chain_factory, dataset_name)
dataset = client.read_dataset(dataset_name=dataset_name)
as_of = dataset_version if isinstance(dataset_version, datetime) else None
if isinstance(dataset_version, str):
raise NotImplementedError(
"Selecting dataset_version by tag is not yet supported."
" Please use a datetime object."
)
examples = list(client.list_examples(dataset_id=dataset.id, as_of=as_of))
examples = list(client.list_examples(dataset_id=dataset.id, as_of=dataset_version))
if not examples:
raise ValueError(f"Dataset {dataset_name} has no example rows.")
modified_at = [ex.modified_at for ex in examples if ex.modified_at]
# Should always be defined in practice when fetched,
# but the typing permits None
max_modified_at = max(modified_at) if modified_at else None
dataset_version = max_modified_at.isoformat() if max_modified_at else None
inferred_version = max_modified_at.isoformat() if max_modified_at else None
try:
project_metadata = project_metadata or {}
@ -1003,7 +998,7 @@ def _prepare_eval_run(
"git": git_info,
}
project_metadata["dataset_version"] = dataset_version
project_metadata["dataset_version"] = inferred_version
project = client.create_project(
project_name,
reference_dataset_id=dataset.id,

View File

@ -3525,13 +3525,13 @@ url = "../text-splitters"
[[package]]
name = "langsmith"
version = "0.1.14"
version = "0.1.17"
description = "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform."
optional = false
python-versions = ">=3.8.1,<4.0"
files = [
{file = "langsmith-0.1.14-py3-none-any.whl", hash = "sha256:ecb243057d2a43c2da0524fe395585bc3421bb5d24f1cdd53eb06fbe63e43a69"},
{file = "langsmith-0.1.14.tar.gz", hash = "sha256:b95f267d25681f4c9862bb68236fba8a57a60ec7921ecfdaa125936807e51bde"},
{file = "langsmith-0.1.17-py3-none-any.whl", hash = "sha256:563e88d8629db23cfd5312b96fd3c6cbf990fdf2abb404d2fba3b76a73f4828f"},
{file = "langsmith-0.1.17.tar.gz", hash = "sha256:1a4aed855a97aae01276c832c6857b3902d910065abdb0de36ae2ad520edd92a"},
]
[package.dependencies]
@ -9132,4 +9132,4 @@ text-helpers = ["chardet"]
[metadata]
lock-version = "2.0"
python-versions = ">=3.8.1,<4.0"
content-hash = "095a661dc5f767d2a3c92541d66c2d3070e86fb455b98f313e6c9a40b699b4ef"
content-hash = "2b679b5f0fd928dce161ca83d167111ad896cbd405931558e9e3dcb83353d8ff"

View File

@ -15,7 +15,7 @@ python = ">=3.8.1,<4.0"
langchain-core = ">=0.1.28,<0.2"
langchain-text-splitters = ">=0.0.1,<0.1"
langchain-community = ">=0.0.25,<0.1"
langsmith = "^0.1.14"
langsmith = "^0.1.17"
pydantic = ">=1,<3"
SQLAlchemy = ">=1.4,<3"
requests = "^2"