Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,13 @@ console.log(result.confidence) // 0.89
console.log(result.risk_score) // 0.85
console.log(result.rationale) // "Multiple grooming indicators..."
console.log(result.recommended_action) // 'immediate_intervention'

// Per-message breakdown (optional, returned on conversation-aware endpoints)
if (result.message_analysis) {
for (const m of result.message_analysis) {
console.log(`Message ${m.message_index}: risk=${m.risk_score}, flags=${m.flags}, summary=${m.summary}`)
}
}
```

#### `detectUnsafe(input)`
Expand Down
16 changes: 16 additions & 0 deletions src/types/detection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@ export interface DetectionCategory {
confidence: number;
}

/**
* Per-message analysis from conversation-aware detection.
*/
export interface MessageAnalysis {
/** Index of the message in the input array */
message_index: number;
/** Risk score for this specific message (0-1) */
risk_score: number;
/** Flags identified in this message */
flags: string[];
/** Brief summary of the message analysis */
summary: string;
}

/**
* Evidence excerpt from the analyzed content.
*/
Expand Down Expand Up @@ -85,6 +99,8 @@ export interface DetectionResult {
recommended_action: string;
/** Explanation of the analysis */
rationale: string;
/** Per-message analysis (conversation-aware endpoints) */
message_analysis?: MessageAnalysis[];
/** Language code used for analysis */
language: string;
/** Language support maturity */
Expand Down
3 changes: 3 additions & 0 deletions src/types/safety.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
GroomingRisk,
} from '../constants.js';
import { TrackingFields } from './index.js';
import { MessageAnalysis } from './detection.js';

// Re-export enums for convenience
export { Severity, GroomingRisk };
Expand Down Expand Up @@ -96,6 +97,8 @@ export interface GroomingResult {
risk_score: number;
/** Recommended action to take */
recommended_action: string;
/** Per-message analysis (conversation-aware endpoints) */
message_analysis?: MessageAnalysis[];
/** Language code used for analysis */
language?: string;
/** Language support maturity */
Expand Down