Multi-tenant platform (182 pages, 228 API routes, ~30 modules) built on a deterministic verification core: clinical-trial claims checked against ClinicalTrials.gov registered results and raw event counts (ARR/NNT/RR+CI recomputed in code, oracle-tested), code-enforced exact-span grounding, and multi-source cross-verification. Auth/RBAC/multi-tenancy, document processing at scale (unpdf + Docling), agentic workflows, Claude Science connector, compliance/audit, billing, public API, and more. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
import { EffectSizeCheck, CrossSourceAgreement, CorroboratingSource, RegistryCheck } from "@/components/VerificationView";
|
|
import { GroundedSpan } from "@/lib/grounding";
|
|
import { ExtractedFinding } from "@/lib/schemas";
|
|
|
|
export interface VerifyResponse {
|
|
status: "verified" | "no_support_found";
|
|
message?: string;
|
|
verification_id?: string | null;
|
|
claim?: string;
|
|
source?: {
|
|
title: string | null;
|
|
url: string;
|
|
source_type: string;
|
|
external_id?: string;
|
|
phase?: string | null;
|
|
enrollment_count?: number | null;
|
|
raw_text: string;
|
|
};
|
|
finding?: ExtractedFinding;
|
|
verification?: {
|
|
discrepancy_type: string;
|
|
trust_score: number;
|
|
explanation: string;
|
|
flagged_spans: GroundedSpan[];
|
|
};
|
|
effect_size_check?: EffectSizeCheck;
|
|
cross_source_agreement?: CrossSourceAgreement;
|
|
corroborating_sources?: CorroboratingSource[];
|
|
registry_check?: RegistryCheck | null;
|
|
}
|
|
|
|
const REQUEST_TIMEOUT_MS = 20000;
|
|
|
|
/** One verify attempt with a bounded timeout. Throws on network error or timeout;
|
|
* resolves with { ok, data } for any HTTP response (including 4xx/5xx JSON). */
|
|
export async function fetchVerify(
|
|
claim: string,
|
|
sourceHint?: string
|
|
): Promise<{ ok: boolean; data: VerifyResponse & { error?: string } }> {
|
|
const controller = new AbortController();
|
|
const timer = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
try {
|
|
const res = await fetch("/api/verify", {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({ claim, source_hint: sourceHint || undefined }),
|
|
signal: controller.signal,
|
|
});
|
|
const data = await res.json();
|
|
return { ok: res.ok, data };
|
|
} finally {
|
|
clearTimeout(timer);
|
|
}
|
|
}
|