Spaces:
Sleeping
Sleeping
feat: add web/lib/types.ts
Browse files- web/lib/types.ts +86 -0
web/lib/types.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// ClauseGuard — Shared TypeScript types for the web app
|
| 2 |
+
|
| 3 |
+
export interface Cat {
|
| 4 |
+
name: string;
|
| 5 |
+
severity: string;
|
| 6 |
+
description?: string;
|
| 7 |
+
confidence?: number;
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
export interface Clause {
|
| 11 |
+
text: string;
|
| 12 |
+
categories: Cat[];
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
export interface Entity {
|
| 16 |
+
text: string;
|
| 17 |
+
type: string;
|
| 18 |
+
score?: number;
|
| 19 |
+
source?: string;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
export interface Contradiction {
|
| 23 |
+
type: string;
|
| 24 |
+
explanation: string;
|
| 25 |
+
severity: string;
|
| 26 |
+
confidence?: number;
|
| 27 |
+
source?: string;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
export interface Obligation {
|
| 31 |
+
type: string;
|
| 32 |
+
party: string;
|
| 33 |
+
description: string;
|
| 34 |
+
deadline: string;
|
| 35 |
+
priority?: number;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
export interface ComplianceCheck {
|
| 39 |
+
requirement: string;
|
| 40 |
+
description: string;
|
| 41 |
+
severity: string;
|
| 42 |
+
status: string;
|
| 43 |
+
matched_keywords: string[];
|
| 44 |
+
context?: string[];
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
export interface ComplianceReg {
|
| 48 |
+
description: string;
|
| 49 |
+
compliance_rate: number;
|
| 50 |
+
checks: ComplianceCheck[];
|
| 51 |
+
overall_status: string;
|
| 52 |
+
negated_count?: number;
|
| 53 |
+
ambiguous_count?: number;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
export interface Redline {
|
| 57 |
+
original_text: string;
|
| 58 |
+
clause_label: string;
|
| 59 |
+
risk_level: string;
|
| 60 |
+
safe_alternative: string;
|
| 61 |
+
template_alternative?: string;
|
| 62 |
+
legal_basis: string;
|
| 63 |
+
consumer_standard: string;
|
| 64 |
+
tier: string;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
export interface ChatMessage {
|
| 68 |
+
role: "user" | "assistant";
|
| 69 |
+
content: string;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
export interface AnalysisResult {
|
| 73 |
+
risk_score: number;
|
| 74 |
+
grade: string;
|
| 75 |
+
total_clauses: number;
|
| 76 |
+
flagged_count: number;
|
| 77 |
+
results: Clause[];
|
| 78 |
+
entities: Entity[];
|
| 79 |
+
contradictions: Contradiction[];
|
| 80 |
+
obligations: Obligation[];
|
| 81 |
+
compliance: Record<string, ComplianceReg>;
|
| 82 |
+
redlines: Redline[];
|
| 83 |
+
model: string;
|
| 84 |
+
latency_ms: number;
|
| 85 |
+
session_id?: string;
|
| 86 |
+
}
|