Created
July 15, 2025 07:36
-
-
Save Dhravya/cc869456baa30e3579c8c236d7ea2b64 to your computer and use it in GitHub Desktop.
Output type for legal AI hallucination cases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const LegalHallucinationAnalysis = z.object({ | |
// Case identification | |
case_id: z.string(), | |
case_name: z.string(), | |
date_occurred: z.string().regex(/^\d{4}-\d{2}-\d{2}$/), | |
ai_model_used: z.string(), | |
source_url: z.string().url().optional(), | |
// Hallucination details | |
hallucination_details: z.object({ | |
type: HallucinationType, | |
specific_false_content: z.string(), | |
correct_information: z.string(), | |
user_query: z.string(), | |
ai_response_excerpt: z.string(), | |
fabricated_citations: z.array(z.string()).optional(), | |
legal_domain: z.string() // e.g., "contract law", "criminal procedure" | |
}), | |
// Context gap analysis | |
context_gap_analysis: z.object({ | |
primary_gap_type: GapType, | |
missing_information: z.string(), | |
information_availability: AvailabilityLevel, | |
training_data_factor: z.boolean(), | |
context_window_overflow: z.boolean(), | |
jurisdictional_confusion: z.boolean(), | |
temporal_information_needed: z.boolean(), // Recent legal changes | |
citation_network_gap: z.boolean() // Missing legal precedent connections | |
}), | |
// Technical failure analysis | |
technical_failure_mode: z.object({ | |
primary_failure: FailureMode, | |
retrieval_failure: z.boolean(), | |
reasoning_failure: z.boolean(), | |
generation_failure: z.boolean(), | |
verification_failure: z.boolean(), | |
attention_mechanism_issue: z.boolean(), | |
token_limit_exceeded: z.boolean(), | |
failure_explanation: z.string() | |
}), | |
// Context preventability scoring (1-10 scale) | |
context_preventability_scores: z.object({ | |
database_access_score: z.number().min(1).max(10), | |
real_time_info_score: z.number().min(1).max(10), | |
training_data_score: z.number().min(1).max(10), | |
context_window_score: z.number().min(1).max(10), | |
verification_score: z.number().min(1).max(10), | |
overall_preventability: z.number().min(1).max(10), | |
confidence_level: ConfidenceLevel, | |
scoring_rationale: z.string() | |
}), | |
// Impact assessment | |
impact_assessment: z.object({ | |
financial_cost: z.number().min(0), // USD | |
court_sanctions: z.number().min(0), // USD | |
reputational_damage: ImpactLevel, | |
legal_consequences: z.array(z.string()), | |
client_impact: ImpactLevel, | |
systemic_risk: SeverityLevel, | |
media_attention: z.boolean(), | |
precedent_setting: z.boolean() | |
}), | |
// Solution requirements | |
solution_requirements: z.object({ | |
required_data_sources: z.array(z.string()), | |
technical_capabilities: z.array(z.string()), | |
verification_mechanisms: z.array(z.string()), | |
implementation_complexity: ComplexityLevel, | |
estimated_cost: ComplexityLevel, | |
development_timeline: TimelineEstimate, | |
infrastructure_requirements: z.array(z.string()) | |
}), | |
// Categorization | |
categorization: z.object({ | |
primary_category: PreventabilityCategory, | |
secondary_categories: z.array(z.string()), | |
severity_level: SeverityLevel, | |
precedent_value: SeverityLevel, | |
industry_impact: SeverityLevel | |
}), | |
// Recommendations | |
recommendations: z.object({ | |
immediate_actions: z.array(z.string()), | |
technical_solutions: z.array(z.string()), | |
policy_changes: z.array(z.string()), | |
industry_implications: z.string(), | |
prevention_strategies: z.array(z.string()) | |
}), | |
// Quality control metadata | |
analysis_metadata: z.object({ | |
analyst_confidence: ConfidenceLevel, | |
analysis_date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/), | |
review_status: z.enum(['pending', 'reviewed', 'validated']), | |
evidence_quality: SeverityLevel, | |
methodology_version: z.string(), | |
potential_biases: z.array(z.string()).optional() | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment