feat(ai): standardize result envelope across AI endpoints (#609)#684
Open
teethaking wants to merge 2 commits into
Open
feat(ai): standardize result envelope across AI endpoints (#609)#684teethaking wants to merge 2 commits into
teethaking wants to merge 2 commits into
Conversation
Add ResultEnvelope[T] to schemas/common.py with fields: result, confidence, reasons, anchor_metadata, trace_id Updated endpoints: OCR, fraud, humanitarian, anonymize, proof-of-life - confidence derived from field scores (OCR), portfolio cleanliness (fraud), LLM output (humanitarian), null for deterministic (anonymize) - reasons populated from flagged claims / LLM reasoning / PII count - trace_id sourced from existing correlation_id_var context var - anchor_metadata passed through unchanged Legacy /ai/* routes in main.py are untouched (no breaking changes) Added tests/test_result_envelope.py; updated existing test suites
|
@teethaking is attempting to deploy a commit to the Cedarich's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@teethaking Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
@teethaking fix workfow |
) - test_main.py: update proof_of_life, anonymize, humanitarian tests to assert on ResultEnvelope fields (result/confidence) instead of old flat shape; humanitarian failure now expects 500 error envelope - test_versioned_routes.py: mock run_ocr_from_bytes in v1 OCR tests to avoid Tesseract dependency in CI; fix humanitarian failure test to use raise_server_exceptions=False client; update parity tests to expect ResultEnvelope from both v1 and legacy redirect paths - test_routes.py: revert OCR processing_time assertion to legacy shape (legacy /ai/ocr route unchanged) - test_result_envelope.py: fix anchor_metadata passthrough test to include anchor in mock return value - test_fraud_detection.py: already fixed in prior commit (result list)
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.
Add ResultEnvelope[T] to schemas/common.py with fields:
result, confidence, reasons, anchor_metadata, trace_id
Updated endpoints: OCR, fraud, humanitarian, anonymize, proof-of-life
Legacy /ai/* routes in main.py are untouched (no breaking changes) Added tests/test_result_envelope.py; updated existing test suites
Closes #609