package validators import ( "context" "gitea.maximumdirect.net/eric/audita/internal/core/schema" "gitea.maximumdirect.net/eric/audita/internal/framework/responseschema" ) type LLMValidatorType string const ( LLMValidatorTypeSpokenFormPlausibility LLMValidatorType = "spoken_form_plausibility" LLMValidatorTypeMeaningReversal LLMValidatorType = "meaning_reversal" LLMValidatorTypeEditorialReview LLMValidatorType = "editorial_review" LLMValidatorTypeGrammarReview LLMValidatorType = "grammar_review" LLMValidatorTypeSpokenWordReview LLMValidatorType = "spoken_word_review" ) type LLMMessage struct { Role string `json:"role"` Content string `json:"content"` } type StructuredCompletionRequest struct { StageName string `json:"stage_name"` Messages []LLMMessage `json:"messages"` Model string `json:"model,omitempty"` ResponseSchema *responseschema.Schema `json:"response_schema,omitempty"` } type StructuredCompletionResponse struct { PromptTokens int `json:"prompt_tokens,omitempty"` CompletionTokens int `json:"completion_tokens,omitempty"` TotalTokens int `json:"total_tokens,omitempty"` } type StructuredLLMClient interface { CompleteStructured(ctx context.Context, req StructuredCompletionRequest, out any) (StructuredCompletionResponse, error) } // LLMValidationItem is one candidate correction payload passed to LLM validators. type LLMValidationItem struct { CorrectionIndex int `json:"correction_index"` SegmentID int `json:"id"` OriginalText string `json:"original_text"` CorrectedText string `json:"corrected_text"` OriginalSegmentText string `json:"original_segment_text"` CorrectedSegmentText string `json:"corrected_segment_text"` Categories []string `json:"categories,omitempty"` } // LLMValidationRequest is the canonical request model for LLM-backed validators. type LLMValidationRequest struct { ValidatorName string `json:"validator_name"` ValidatorType LLMValidatorType `json:"validator_type"` ModuleKey string `json:"module_key"` ModuleInstance string `json:"module_instance"` ReplacementPolicy string `json:"replacement_policy"` Glossary *schema.Glossary `json:"-"` Items []LLMValidationItem `json:"corrections"` } type LLMValidationDecision struct { CorrectionIndex int `json:"correction_index"` Approved bool `json:"approved"` Confidence float64 `json:"confidence"` Reason string `json:"reason"` } type LLMValidationResponse struct { Validations []LLMValidationDecision `json:"validations"` }