Skip to content

feat(ai-service): stateless extraction service with grounding verifier #6

Description

@Fluory

Goal

services/ai exposes POST /v1/extract (contract contracts/ai-service.openapi.yaml): docling parses PDF and EML into segments with locators, Gemini on Vertex eu extracts three header fields, and a deterministic verifier checks every quote.

Acceptance criteria

  • OpenAPI 3.1 contract committed; TS client/types generated from it
  • Segments carry stable locators (PDF: page + bounding box, EML: body line)
  • Per field: value | null, status found/uncertain/missing, evidence {segmentId, quote} for company, contact person, requested delivery date
  • Verifier (test-first): quote not found (normalised) in the cited segment, or value inconsistent with the quote → unverified
  • No database or storage credentials; bearer-token auth; logs without document content
  • Model and region from configuration; the Gemini free tier only with an explicit dev flag and never as a silent fallback (fail-closed)
  • PR documents the verified docling EML/MSG coverage and the SDK configuration for the eu endpoint (ADR-0001 open points)

Not part of this task

  • All fields and positions, XLSX/DOCX/MSG/scans, eval gate (Epic 2)

Affected areas

  • services/ai/
  • contracts/ai-service.openapi.yaml

Test plan

Criterion Check
grounding verifier pytest unit tests incl. normalisation of numbers and dates
contract contract test against the OpenAPI schema
end to end pytest with a recorded model response at the HTTP boundary (synthetic mail)

Security/Privacy affected?

Yes – document content reaches an external LLM: EU endpoint, synthetic data only, no content in logs. Prompt-injection case in the tests.

Epic: #2 · Architecture: docs/decisions/ADR-0001-pilot-architecture.md

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

aiLLM, prompts, evalsfeatureNew capabilityreadyDefinition of Ready met – may be claimed

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions