Add structured output format validation helpers#386
Open
ECNUACRush wants to merge 2 commits into
Open
Conversation
Changed Files
|
|
Heads up: I opened #387 for this same issue a few minutes after you filed this, without seeing yours first. Yours is more complete (XML support plus the FAQ docs), so I'm closing mine in favor of it. One small edge case my tests covered that might be worth folding in: a |
Author
|
Thanks for the heads up, and no worries. I appreciate you closing yours. @mvanhorn Good catch on the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #265.
This PR adds evaluator wrappers for structured-output validation:
require_json_outputrequire_xml_outputrequire_regex_matchrequire_formatWhen validation fails, the wrapper returns
score=0.0and includes the parse or validation error inside_info, so GEPA's reflection step can learn from format failures.This is related to #379/#384, but intentionally limited to evaluator-side format failure feedback. It does not implement rejected-proposal memory.
Tests
python -m pytest -qpython -m ruff check src/gepa/utils/format_validation.py src/gepa/utils/__init__.py tests/test_format_validation.py docs/docs/guides/faq.mdpython -m pyright --pythonversion 3.12 src/gepa/utils/format_validation.pymkdocs build -f docs/mkdocs.yml