import { useState } from "react"; import { BrainCircuit, FileSearch, Gauge, Github, Sparkles, Wrench } from "lucide-react"; import { api, setTokens } from "../lib/api.js"; export default function AuthPage({ onAuthed, appInfo }) { const [mode, setMode] = useState("login"); const [email, setEmail] = useState(""); const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(""); const [busy, setBusy] = useState(false); const [demoBusy, setDemoBusy] = useState(false); const isDemo = Boolean(appInfo?.demo_mode); async function startDemo() { setError(""); setDemoBusy(true); try { const response = await fetch("/api/auth/demo", { method: "POST" }); const data = await response.json(); if (!response.ok) { throw new Error( typeof data.detail === "string" ? data.detail : "Could not start the demo. Please try again." ); } setTokens(data); onAuthed(await api("/api/auth/me")); } catch (err) { setError(err.message); } finally { setDemoBusy(false); } } async function submit(event) { event.preventDefault(); setError(""); setBusy(true); try { const path = mode === "login" ? "/api/auth/login" : "/api/auth/register"; const body = mode === "login" ? { email, password } : { email, username, password }; const response = await fetch(path, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body), }); const data = await response.json(); if (!response.ok) { throw new Error( typeof data.detail === "string" ? data.detail : "Please check your details and try again." ); } setTokens(data); onAuthed(await api("/api/auth/me")); } catch (err) { setError(err.message); } finally { setBusy(false); } } return (
Synapse

Your agentic AI assistant,
with real superpowers.

Streaming chat backed by an autonomous tool-calling agent, hybrid retrieval over your documents, and full cost observability.

Agentic tool use Web search, weather, calculator and document retrieval, chosen autonomously.
Hybrid RAG with citations BM25 + dense vectors fused with RRF, reranked, and cited inline.
Built-in observability Token, cost and latency analytics for every conversation.
{isDemo ? ( <>

Try the live demo

One click, no signup. You get a private sandbox preloaded with a sample report so document retrieval works immediately.

{error &&
{error}
}
  • Ask about the weather or search the web, the agent picks its own tools
  • Ask about the preloaded report to see hybrid RAG with citations
  • Upload your own PDF, or open Analytics for live token and cost metrics
{appInfo?.repo_url && ( View the source on GitHub )}
or use an account
) : ( <>

{mode === "login" ? "Welcome back" : "Create your account"}

{mode === "login" ? "Sign in to continue your conversations." : "A minute from now you will be chatting with Synapse."}

{error &&
{error}
} )} {mode === "register" && (
setUsername(e.target.value)} placeholder="What should we call you?" required minLength={2} />
)}
setEmail(e.target.value)} placeholder="you@example.com" required />
setPassword(e.target.value)} placeholder={mode === "register" ? "At least 8 characters" : "Your password"} required minLength={8} />
{mode === "login" ? "New to Synapse?" : "Already have an account?"}{" "}
); }