feat(pipeline): GenAIStep (spec §6.3, §7, §9.2) #14

Merged
goldstein merged 1 commit from feat/step-genai into main 2026-04-18 09:19:00 +00:00
Owner

Chunk 2, Task 2.6.

LLM-call step: assembles the prompt, picks plain vs ProvenanceWrappedResponse schema, calls GenAIClient, maps segment_citations into response.provenance.

Tests

17 new tests (174 total). uv run pytest tests/unit -q -> 174 passed. uv run ruff check src tests -> clean.

Merge gate

Forgejo Actions trigger bug is still in effect — local test + ruff are the gate.

Chunk 2, Task 2.6. LLM-call step: assembles the prompt, picks plain vs ProvenanceWrappedResponse schema, calls GenAIClient, maps segment_citations into response.provenance. ## Tests 17 new tests (174 total). `uv run pytest tests/unit -q` -> 174 passed. `uv run ruff check src tests` -> clean. ## Merge gate Forgejo Actions trigger bug is still in effect — local test + ruff are the gate.
goldstein added 1 commit 2026-04-18 09:18:54 +00:00
feat(pipeline): GenAIStep — LLM call + provenance mapping (spec §6.3, §7, §9.2)
All checks were successful
tests / test (push) Successful in 1m14s
tests / test (pull_request) Successful in 1m10s
abee9cea7b
Assembles the prompt, picks the structured-output schema, calls the
injected GenAIClient, and maps any emitted segment_citations into
response.provenance. Reliability flags stay None here; ReliabilityStep
fills them in Task 2.7.

- System prompt = use_case.system_prompt + (provenance-on) the verbatim
  citation instruction from spec §9.2.
- User text = SegmentIndex.to_prompt_text([p1_l0] style) when provenance
  is on, else plain OCR flat text + texts joined.
- Response schema = UseCaseResponse directly, or a runtime
  create_model("ProvenanceWrappedResponse", result=(UCR, ...),
  segment_citations=(list[SegmentCitation], Field(default_factory=list)))
  when provenance is on.
- Model = request override -> use-case default.
- Failure modes: httpx / connection / timeout errors -> IX_002_000;
  pydantic.ValidationError -> IX_002_001.
- Writes ix_result.result + ix_result.meta_data (model_name +
  token_usage); builds response.provenance via
  map_segment_refs_to_provenance when provenance is on.

17 unit tests in tests/unit/test_genai_step.py cover validate
(ocr_only skip, empty -> IX_001_000, text-only, ocr-text path), process
happy path, system-prompt shape with/without citation instruction, user
text tagged vs. plain, response schema plain vs. wrapped, provenance
mapping, error mapping (IX_002_000 + IX_002_001), and model selection
(request override + use-case default).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
goldstein merged commit 6d9c239e82 into main 2026-04-18 09:19:00 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: goldstein/infoxtractor#14
No description provided.