"use client"; import { useState } from "react"; import { graphQuery, getGraphStats } from "@/lib/api"; import { MessageSquare, Loader2, Database } from "lucide-react"; import { useEffect } from "react"; const SAMPLE_QUESTIONS = [ "Which patients are eligible for breast cancer trials?", "What trials are in Phase II?", "List all patients with HER2 positive biomarker", "How many active trials are there for prostate cancer?", "Which study sites have the most active trials?", ]; export default function GraphPage() { const [question, setQuestion] = useState(""); const [response, setResponse] = useState(""); const [loading, setLoading] = useState(false); const [error, setError] = useState(""); const [stats, setStats] = useState(null); useEffect(() => { getGraphStats().then(setStats).catch(() => {}); }, []); const handleQuery = async (q = question) => { if (!q.trim()) return; setLoading(true); setError(""); setResponse(""); setQuestion(q); try { const data = await graphQuery(q); setResponse(data.response); } catch (e: any) { setError(e.message); } setLoading(false); }; return (

Graph RAG

Ask natural language questions about the clinical trial knowledge graph

{stats && (
{Object.entries(stats).map(([k, v]: any) => (
{v} {k}
))}
)}

Sample Questions

{SAMPLE_QUESTIONS.map((q) => ( ))}
setQuestion(e.target.value)} onKeyDown={(e) => e.key === "Enter" && handleQuery()} placeholder="Ask anything about patients, trials, or biomarkers..." className="flex-1 border border-slate-200 rounded-lg px-4 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white" />
{error && (
{error}
)} {response && (
Response

{response}

)}
); }