Skip to content

Fix some issues with non-serializable inputs in evals #1333

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 3 commits into from
Apr 1, 2025

Conversation

dmontagu
Copy link
Contributor

@dmontagu dmontagu commented Apr 1, 2025

I realized I shouldn't have been eagerly dumping to JSON, I used to do that because I wanted inputs to be a dict[str, Any] but there was never really a benefit to that and we did change the default type for inputs to Any. And it just isn't necessary for the rendering. So I think this is better.

Closes #1325

I think this addresses the main issue reported in https://pydanticlogfire.slack.com/archives/C083V7PMHHA/p1743485529924179

@@ -83,6 +83,8 @@ def _stringify(value: Any) -> str:
if isinstance(value, str):
return value
try:
# If the value can be serialized to JSON, use that.
# If that behavior is undesirable, the user could manually call repr on the arguments to the judge_* functions
return to_json(value).decode()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I at first thought that we should remove the JSON serialization here too, and I'm still not confident we shouldn't, but you do have the option to call repr on the inputs before passing them to the judge_ functions. Admittedly, you'd need to make a custom evaluator to do that, but 🤷‍♂️ I'm not convinced this is wrong yet. Would be happy to change it to just use repr rather than json serializing if others feel strongly that that's better though.

Copy link

github-actions bot commented Apr 1, 2025

Docs Preview

commit: f4000e6
Preview URL: https://00be8de6-pydantic-ai-previews.pydantic.workers.dev

@dmontagu dmontagu enabled auto-merge (squash) April 1, 2025 21:56
@dmontagu dmontagu merged commit ebd86fa into main Apr 1, 2025
16 checks passed
@dmontagu dmontagu deleted the dmontagu/evals-fix-non-serializable-inputs branch April 1, 2025 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom types and custom inputs in pydantic-evals
1 participant