Repository navigation
fix(python): await custom scorers in JSONDiff async evaluations - #258
Open
Bin (xlb3055) wants to merge 1 commit into
Open
Bin (xlb3055) wants to merge 1 commit into
Bin (xlb3055) wants to merge 1 commit into
Conversation
This branch has not been deployed
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
JSONDiff.eval_async()currently falls back to the synchronous JSON traversal and calls custom scorers througheval(). The documentedAsyncOpenAI+EmbeddingSimilarityexample consequently raisesAttributeError: 'coroutine' object has no attribute 'dict'when a nested string is scored, leaving an unawaited coroutine.Add asynchronous recursive traversal that awaits string and number scorers through their public
eval_async()methods. Keep the synchronous traversal, parsing rules, aggregation formulas and existing scalar handling unchanged. The TypeScript implementation already awaits its custom scorers.Tests cover nested dictionaries/lists, JSON-encoded inputs, custom async string/number scorers, mixed-type fallback, partial scorers, synchronous score parity, and the real
AsyncOpenAI/EmbeddingSimilaritypath usinghttpx.MockTransport. No provider requests are made.Validation
pre-commit run --all-files: passed.git diff --check: passed.The full provider-backed suite and remaining Python versions were not run. An initial broader selection included the existing
test_partialcase, which invokes liveClosedQAand failed for missing OpenAI credentials; the final selection consists of offline tests only. No real credentials, model weights, or API calls were used.AI assistance: OpenAI Codex investigated, implemented, self-reviewed, and tested this patch under the account owner's authorization. No separate human review is claimed.