Skip to content

Improve some error messages #1366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions pydantic_evals/pydantic_evals/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,9 @@ def _params(cls) -> tuple[type[InputsT], type[OutputT], type[MetadataT]]:
return args
else: # pragma: no cover
warnings.warn(
f'Could not determine the generic parameters for {cls}; using `Any` for each. '
f'You should explicitly set the generic parameters via `Dataset[MyInputs, MyOutput, MyMetadata]`'
f'when serializing or deserializing.',
f'Could not determine the generic parameters for {cls}; using `Any` for each.'
f' You should explicitly set the generic parameters via `Dataset[MyInputs, MyOutput, MyMetadata]`'
f' when serializing or deserializing.',
UserWarning,
)
return Any, Any, Any # type: ignore
Expand Down Expand Up @@ -1069,7 +1069,8 @@ def _load_evaluator_from_registry(
evaluator_class = registry.get(spec.name)
if evaluator_class is None:
raise ValueError(
f'Evaluator {spec.name!r} is not in the provided registry. Registered choices: {list(registry.keys())}'
f'Evaluator {spec.name!r} is not in the provided `custom_evaluator_types`. Valid choices: {list(registry.keys())}.'
f' If you are trying to use a custom evaluator, you must include its type in the `custom_evaluator_types` argument.'
)
try:
return evaluator_class(*spec.args, **spec.kwargs)
Expand Down
4 changes: 2 additions & 2 deletions tests/evals/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,10 +611,10 @@ async def test_from_text_failure():
'2 error(s) loading evaluators from registry',
[
ValueError(
"Evaluator 'NotAnEvaluator' is not in the provided registry. Registered choices: ['Equals', 'EqualsExpected', 'Contains', 'IsInstance', 'MaxDuration', 'LLMJudge', 'HasMatchingSpan']"
"Evaluator 'NotAnEvaluator' is not in the provided `custom_evaluator_types`. Valid choices: ['Equals', 'EqualsExpected', 'Contains', 'IsInstance', 'MaxDuration', 'LLMJudge', 'HasMatchingSpan']. If you are trying to use a custom evaluator, you must include its type in the `custom_evaluator_types` argument."
),
ValueError(
"Evaluator 'NotAnEvaluator' is not in the provided registry. Registered choices: ['Equals', 'EqualsExpected', 'Contains', 'IsInstance', 'MaxDuration', 'LLMJudge', 'HasMatchingSpan']"
"Evaluator 'NotAnEvaluator' is not in the provided `custom_evaluator_types`. Valid choices: ['Equals', 'EqualsExpected', 'Contains', 'IsInstance', 'MaxDuration', 'LLMJudge', 'HasMatchingSpan']. If you are trying to use a custom evaluator, you must include its type in the `custom_evaluator_types` argument."
),
],
)
Expand Down