feat(pipeline): GenAIStep (spec §6.3, §7, §9.2) #14
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/step-genai"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.
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>