import React, { useState } from 'react'; import { ToxicityPredictionResult } from '../types'; import { Sparkles, X, Bot, FileText, CheckCircle2, Loader2, ShieldAlert } from 'lucide-react'; interface GeminiSafetyModalProps { isOpen: boolean; onClose: () => void; prediction: ToxicityPredictionResult; } export const GeminiSafetyModal: React.FC = ({ isOpen, onClose, prediction }) => { const [reportText, setReportText] = useState(null); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); if (!isOpen) return null; const handleGenerateReport = async () => { setIsLoading(true); setError(null); try { const response = await fetch('/api/ml-advisor', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ compoundName: prediction.compoundName, smiles: prediction.smiles, organScores: { liver: prediction.organScores.liver.meanRisk, heart: prediction.organScores.heart.meanRisk, kidney: prediction.organScores.kidney.meanRisk, brain: prediction.organScores.brain.meanRisk, lung: prediction.organScores.lung.meanRisk }, tanimoto: prediction.tanimotoSimilarity, mcUncertainty: prediction.organScores.liver.uncertaintySigma, useTissueConditioning: prediction.useTissueConditioning }) }); const data = await response.json(); if (data.error) throw new Error(data.error); setReportText(data.advice); } catch (err: any) { setError(err.message || 'Failed to communicate with AI Safety Advisor'); } finally { setIsLoading(false); } }; return (
{/* Modal Header */}

Gemini Preclinical AI Safety Advisor

Automated Medicinal Chemistry & Preclinical Safety Synthesis Report

{/* Compound Info Quick Strip */}
Query Compound {prediction.compoundName}
SMILES {prediction.smiles}
Tissue Mode {prediction.useTissueConditioning ? 'GTEx V8 Active' : 'Baseline'}
{/* Modal Body */}
{!reportText && !isLoading && (

Click below to generate an authoritative Preclinical Safety & Wet-Lab Assay Recommendation Report powered by Gemini 2.5.

)} {isLoading && (

Synthesizing GTEx transcriptomic cross-attention data & chemical toxicophores...

)} {error && (
Error Generating Report

{error}

)} {reportText && (
{reportText}
)}
{/* Modal Footer */}
Powered by @google/genai & EpiADR-Net Engine
); };