Repository navigation
Conversation
|
I ran the branch: 403 tests pass and mypy is clean, so nothing is broken. The part I want to decide separately is dict returns from Could you split the PR?
|
Vedantgitbot
left a comment
There was a problem hiding this comment.
Thanks @rk042, good work overall. Details of the dict-return concern are in my comment above. Requested changes for the split-out parse_fn PR:
Scope
- Remove the dict-return path (
call_fnreturning a dict); it goes in a follow-up PR once I've decided the semantics. Restore the v0.5.4 behavior and tests: a dict return is a call failure (call_failed=True, "expected str"), and{"answer": "x"}stays in the parametrized list intest_v054_regressions.py. Thetest_v048_regressions.pyrename and rewrite should be reverted too. -
ParseFn = Callable[[str], Optional[dict]]. ANoneresult is a parse failure, as in the issue.
Tests (use import booth and pytest.raises, no sys.path.insert)
- non-callable
parse_fnraisesTypeErrorbefore anycall_fncall -
acheck()withparse_fn -
parse_fnreturningNone, and a non-dict value, is a parse failure (notcall_failed) -
parse_fnresult that fails validation (for example confidence out of range) -
"ambiguous": truefromparse_fngivesAMBIGUOUS -
parse_fn=Noneleaves default behavior unchanged
Docs
- TUTORIAL: add
parse_fnandParseFnas new sub-sections without renumbering existing ones, and addparse_fnto the quick-reference table. - Say clearly that retry prompts are unchanged: after a failed
parse_fnresult the JSON-style retry prompt is still sent, so structured-output users may prefermax_retries=0. - CHANGELOG: one entry under
[Unreleased], no version bump (this ships in a minor release).
Process
- For changes to
core.py, please wait for a decision on the issue before opening a PR, since #6 had an open design question.
Happy to re-review quickly once it's updated.
|
hey @Vedantgitbot , Thanks for clarifying. I understand the design question is how direct dict returns from call_fn should behave. Option A: keep PR #26 parse_fn-only. call_fn must return str, parse_fn converts it to dict, and direct dict returns keep the v0.5.4 behavior: call_failed=True, "expected str". Option B: support direct dict returns in a follow-up, after defining the behavior for missing keys and dict + parse_fn. I’ll proceed with Option A for PR #26 and leave direct dict returns out until Issue #6 is decided. |
|
Thanks, understood. I’ll update PR #26 according to the checklist and ping you once the changes, tests, mypy, and documentation are complete. |
@Vedantgitbot Thanks for the design decision. I updated PR #26 according to the checklist:
Verification: 396 tests passed, 6 skipped, and mypy is clean. Ready for re-review. |
What does this change?
Adds a structured-output escape hatch for
check()andacheck().Callers can now either:
call_fn.parse_fnfor provider-specific string decoding.Both paths use the existing
Attempt, validation, retry, confidence, ambiguity, andBoothResultpipeline.Fixes #6
Why?
Some providers already return structured data, so forcing those responses through regex and
raw_decodestring extraction is unnecessary and fragile.This keeps the current architecture intact: