File size: 1,252 Bytes
c6cfe5f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d0ec498
 
 
 
 
 
 
 
 
 
 
5eed8db
 
 
14a3550
d0ec498
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import type { CodingResult, GalleryItem } from "./types";

const JSON_HEADERS = { "Content-Type": "application/json" };

export async function codeNote(text: string, noteId = "adhoc"): Promise<CodingResult> {
  const res = await fetch("/api/code", {
    method: "POST",
    headers: JSON_HEADERS,
    body: JSON.stringify({ text, note_id: noteId }),
  });
  if (!res.ok) throw new Error(`API error: ${res.status} ${await res.text()}`);
  return res.json();
}

export async function fetchGallery(): Promise<GalleryItem[]> {
  const res = await fetch("/api/gallery");
  if (!res.ok) throw new Error(`Gallery fetch failed: ${res.status}`);
  return res.json();
}

export interface ServerStatus {
  status: "ok" | "degraded";
  version: string;
  pipeline_ready: boolean;
  reference_counts: {
    hcc_labels?: number;
    hcc_crosswalk_icd10?: number;
  };
  gallery_size: number;
  metrics_available: boolean;
  meat_llm_configured?: boolean;
  meat_llm_model?: string | null;
  meat_llm_ready?: boolean | null;
  startup_errors?: Record<string, string>;
}

export async function fetchStatus(): Promise<ServerStatus> {
  const res = await fetch("/api/status");
  if (!res.ok) throw new Error(`Status fetch failed: ${res.status}`);
  return res.json();
}