Implement OpenAI two‑pass ETS extraction pipeline with QC, review integration, migrations and tests#239
Open
karilint wants to merge 10 commits intocodex/prepare-implementation-plan-for-recode-extractionfrom
Conversation
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.
Motivation
Description
app/recode_extraction/adapters/openai_client.pyand prompt templates inapp/recode_extraction/services/openai_two_pass_prompts.py.app/recode_extraction/services/trait_vocabulary.py.app/recode_extraction/services/qc.pyand wired it into the pipeline.openai_two_passbackend: per‑page PASS1 evidence extraction, merged evidence persistence, PASS2 structuring, QC → create candidates withets_payloadinExtractedAssertionModel; legacy pipeline preserved in_run_legacy_pipeline(seeapp/recode_extraction/services/orchestrator.py).persist_approved_assertions_to_etswill import prefilledets_payload(and re‑normalize when curators edit values/units) inapp/recode_extraction/services/review.py.pass1_evidence_package,pass2_structured_package,qc_summaryonSourceExtractionRun, andqc_errors+ largerunmapped_reasononExtractedAssertionModel(app/recode_extraction/migrations/0006_openai_two_pass_fields.py,app/recode_extraction/models.py).app/config/settings.pyandapp/recode_extraction/templates/*.app/tests/recode_extraction/test_openai_two_pass_pipeline.pyandapp/tests/recode_extraction/test_openai_qc_normalization.py, and updated review tests to cover prefilled ETS payload persistence.docs/recode_integration.md) andapp/requirements.txt(openai,pydantic), and kept the NE/RE graph pipeline out of production paths.Testing
python -m py_compileon new modules and related tests and they passed locally in this environment.tests/recode_extraction/test_openai_two_pass_pipeline.pyandtests/recode_extraction/test_openai_qc_normalization.pywhich mock the OpenAI client andPdfToTextServiceso no network calls occur.pytest --ds=config.settings ...but the Django test harness failed during DB setup in this environment due to missing/None MySQLNAME(CI/local DB config not available here), so automated Django tests could not complete; failures are environmental and not logic failures in added code.0006_openai_two_pass_fields.pyto add JSON fields andqc_errors; run ofmakemigrationswas prepared and migration committed.Files of primary interest:
app/recode_extraction/adapters/openai_client.py,app/recode_extraction/services/{openai_two_pass_prompts.py,trait_vocabulary.py,qc.py,openai_two_pass.py},app/recode_extraction/services/orchestrator.py,app/recode_extraction/services/review.py,app/recode_extraction/models.py,app/recode_extraction/migrations/0006_openai_two_pass_fields.py, tests underapp/tests/recode_extraction/and docs updatedocs/recode_integration.md.If you want, I can: run the test matrix inside a configured CI (with DB), trim or extend prompt examples, or split the PR into smaller PRs (prompts/client + orchestrator + QC + UI) for easier review.
Codex Task