Repository navigation
Description
Parent
Branch
Branch from stateless_core and open the pull request against it, not main. Close this ticket by hand once its pull request merges there: GitHub only closes issues automatically on merges into main.
What to build
The request, result and error types every later task builds on. A caller can construct a SourcesInput or a PromptInput, read a Detection with its spans, tokens, detail, usage and warnings, and catch InvalidInputError, ConfigurationError and UpstreamError by class and by stable code. The types hold no logic and no detector uses them yet.
Where Chunk, Span, Usage and the error classes live is decided elsewhere: this task is blocked until that decision is made, and it implements the types where the decision puts them.
Acceptance criteria
-
SourcesInput,PromptInput,DetectRequest,DetectedSpan,TokenScore,DetailedResultandDetectionhave the fields, names and defaults in the epic's Implementation Decisions, andChunk,SpanandUsageexist as the shared-types decision places them. -
Detection.tokensandDetection.detaildefault toNone, andusageandwarningsdefault to empty lists. - For each type,
model_validate_json(model_dump_json())gives an equal object, and aDetectRequestvalidated from JSON becomes aSourcesInputor aPromptInputaccording tokind. - The types are frozen: assigning to a field raises.
- Models that hold customer text hide the input in validation errors: a validation error for a bad
SourcesInputdoes not contain the answer or a source text. -
InvalidInputError,ConfigurationErrorandUpstreamErrorexist, every error has acode,InvalidInputErrorhas aparam, and the message of an error built from a request does not contain customer text. - A result warning has a stable
code; its other fields follow the shared-types decision. - The types and errors are importable from
lettucedetect.detectors, andpydantic2.x is a direct dependency. - No detector changes, and the existing tests pass.
- The changed code follows the Errors and logging section of
CONTRIBUTING.md, and no customer text is logged outsidelettucedetect.content.
Blocked by
#132, and the decision elsewhere on where the shared types and error classes live (see Further Notes in #126).
User stories covered
1, 2
Activity
Merge pull request #187 from KRLabsOrg/137-build-detect-requests-and-…