Add Ollama status checks and Docker deployment
This commit is contained in:
@@ -30,11 +30,21 @@ type DashboardSnapshot = {
|
||||
chart: Array<{ date: string; expensesCents: number; paychecksCents: number }>;
|
||||
};
|
||||
|
||||
type OllamaStatus = {
|
||||
available: boolean;
|
||||
configuredModel: string;
|
||||
configuredUrl: string;
|
||||
installedModels: string[];
|
||||
modelReady: boolean;
|
||||
message: string;
|
||||
};
|
||||
|
||||
export function HomeDashboard() {
|
||||
const [selectedMonth, setSelectedMonth] = useState(getCurrentMonthKey());
|
||||
const [snapshot, setSnapshot] = useState<DashboardSnapshot | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [insightBusy, setInsightBusy] = useState(false);
|
||||
const [ollamaStatus, setOllamaStatus] = useState<OllamaStatus | null>(null);
|
||||
|
||||
async function loadDashboard(month: string) {
|
||||
const response = await fetch(`/dashboard?month=${month}`, { cache: "no-store" });
|
||||
@@ -57,6 +67,16 @@ export function HomeDashboard() {
|
||||
return () => window.clearTimeout(timeoutId);
|
||||
}, [selectedMonth]);
|
||||
|
||||
useEffect(() => {
|
||||
const timeoutId = window.setTimeout(async () => {
|
||||
const response = await fetch("/ollama/status", { cache: "no-store" });
|
||||
const payload = (await response.json()) as OllamaStatus;
|
||||
setOllamaStatus(payload);
|
||||
}, 0);
|
||||
|
||||
return () => window.clearTimeout(timeoutId);
|
||||
}, []);
|
||||
|
||||
const topCategoryLabel = useMemo(() => {
|
||||
if (!snapshot?.comparisons.highestCategory) {
|
||||
return "No category leader yet";
|
||||
@@ -161,6 +181,38 @@ export function HomeDashboard() {
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="mt-6 rounded-3xl border border-stone-200 bg-stone-50 px-5 py-4">
|
||||
<div className="flex flex-wrap items-center justify-between gap-3">
|
||||
<div>
|
||||
<p className="text-xs uppercase tracking-[0.2em] text-stone-500">Ollama runtime</p>
|
||||
<p className="mt-2 text-sm font-medium text-stone-700">
|
||||
{ollamaStatus?.message ?? "Checking local runtime status..."}
|
||||
</p>
|
||||
</div>
|
||||
<div className="rounded-full px-3 py-2 text-xs font-semibold uppercase tracking-[0.2em] text-white "
|
||||
data-ready={ollamaStatus?.available && ollamaStatus?.modelReady ? "true" : "false"}
|
||||
>
|
||||
<span
|
||||
className={
|
||||
ollamaStatus?.available && ollamaStatus?.modelReady
|
||||
? "rounded-full bg-emerald-600 px-3 py-2"
|
||||
: "rounded-full bg-stone-500 px-3 py-2"
|
||||
}
|
||||
>
|
||||
{ollamaStatus?.available && ollamaStatus?.modelReady ? "Ready" : "Needs attention"}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-4 grid gap-3 text-sm text-stone-600 sm:grid-cols-2">
|
||||
<p>
|
||||
Model: <span className="font-semibold text-stone-900">{ollamaStatus?.configuredModel ?? "-"}</span>
|
||||
</p>
|
||||
<p>
|
||||
URL: <span className="font-semibold text-stone-900">{ollamaStatus?.configuredUrl ?? "-"}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{snapshot?.insight ? (
|
||||
<div className="mt-6 grid gap-4 lg:grid-cols-[1.2fr_0.8fr]">
|
||||
<article className="rounded-3xl border border-stone-200 bg-[#fffcf7] px-5 py-5">
|
||||
|
||||
Reference in New Issue
Block a user