diff --git a/apps/admin-ui/src/app/corpora/page.tsx b/apps/admin-ui/src/app/corpora/page.tsx index 7b06f11..9616187 100644 --- a/apps/admin-ui/src/app/corpora/page.tsx +++ b/apps/admin-ui/src/app/corpora/page.tsx @@ -26,7 +26,8 @@ import { TableSkeleton, Textarea, } from "@/components/ui/primitives"; -import { fetchCorpora } from "@/lib/api"; +import { createCorpus, deleteCorpus, fetchCorpora } from "@/lib/api"; +import { GATEWAY_URL } from "@/lib/config"; import { CORPORA } from "@/lib/mock"; import { absTime, relTime } from "@/lib/time"; import type { Corpus } from "@/lib/types"; @@ -188,9 +189,35 @@ export default function CorporaPage() { {creating && ( setCreating(false)} - onCreate={(corpus) => { + onCreate={async ({ display_name, description, embedding_model, embedding_dimension }) => { + let corpus: Corpus; + if (GATEWAY_URL && source === "live") { + try { + corpus = await createCorpus(tenant.id, { + display_name, + description, + embedding_model, + embedding_dimension, + }); + } catch { + toast({ title: "Failed to create corpus", variant: "error" }); + return; + } + } else { + corpus = { + id: "corpus_" + Math.random().toString(16).slice(2, 14), + tenant_id: tenant.id, + display_name, + description, + embedding_model, + embedding_dimension, + document_count: 0, + created_at: new Date().toISOString(), + updated_at: new Date().toISOString(), + metadata: {}, + }; + } setRows((prev) => [corpus, ...prev]); setCreating(false); toast({ title: "Corpus created", description: corpus.display_name, variant: "success" }); @@ -214,8 +241,15 @@ export default function CorporaPage() {