Skip to content

Feat/humanitarian verification v2 parsing#375

Merged
kilodesodiq-arch merged 3 commits into
ChainForgee:mainfrom
Opulencechuks:feat/humanitarian-verification-v2-parsing
Jul 17, 2026
Merged

Feat/humanitarian verification v2 parsing#375
kilodesodiq-arch merged 3 commits into
ChainForgee:mainfrom
Opulencechuks:feat/humanitarian-verification-v2-parsing

Conversation

@Opulencechuks

Copy link
Copy Markdown
Contributor

Closes #269

Summary

This PR unifies the parsing logic for humanitarian verification responses across OpenAI, Groq, and the Test provider. It introduces a version 2 schema (HumanitarianVerificationResponseV2) to ensure that callers receive stable, identical-shape responses across all provider pathways, resolving the issue where responses built out-of-band or truncated mid-token could break verification endpoint expectations.

  • Unified Parsing: Added parse_verification_response and _normalize_verification_dict in humanitarian_verification.py to handle markdown block stripping, missing keys padding, and regex-based recovery parsing for mid-token truncated JSON responses.
  • Metadata Stamp: Every response now includes a deterministic stamp dictionary referencing the provider, model, and prompt_variant.
  • V2 Schemas: Created app/ai-service/schemas/humanitarian_verification_v2.py implementing HumanitarianVerificationResponseV2 and HumanitarianVerificationDetailsV2.

Testing

Tests were added and verified to ensure compatibility and schema correctness across all three providers.

# Run schema and verification tests
pytest app/ai-service/tests/test_schemas.py -v
pytest app/ai-service/tests/test_humanitarian_verification.py -v

Screenshots

(No UI changes; backend service APIs and schemas update only.)

Checklist

  • Tests added or updated for new/changed behavior
  • Existing tests pass
  • No secrets, keys, or seed phrases committed
  • Follows the coding conventions in the relevant service README
  • PR is focused on a single concern

Copy link
Copy Markdown
Contributor

Awesome work on this! Thanks for the contribution 🚀 Merging now.

@kilodesodiq-arch
kilodesodiq-arch merged commit 7d9b929 into ChainForgee:main Jul 17, 2026
7 checks passed
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.

humanitarian_verification response shape parity between OpenAI / Groq / Test

2 participants