File size: 3,487 Bytes
6754826 7f73287 6754826 7f73287 6754826 | 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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | async function _request(url, opts = {}) {
const res = await fetch(url, opts);
if (!res.ok) {
const err = await res.json().catch(() => ({ detail: res.statusText }));
throw new Error(`${res.status}: ${JSON.stringify(err)}`);
}
return res.json();
}
function _post(url, body) {
return _request(url, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
});
}
export const getConfig = () => _request("/api/check");
export const getPersonas = () => _request("/api/personas");
export const createToken = (data) => _post("/api/session/token", data);
export const getRagStatus = () => _request("/api/rag/status");
export const getRagDocuments = () => _request("/api/rag/documents");
export const deleteRagDocument = (id) => _request(`/api/rag/documents/${id}`, { method: "DELETE" });
export const getRagPrompt = () => _request("/api/rag/persona");
export const updateRagPrompt = (prompt, languageCode) =>
_request("/api/rag/persona", {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ system_prompt: prompt, language_code: languageCode || null }),
});
export const resetRag = () => _post("/api/rag/reset", {});
export async function uploadRagFile(file) {
const form = new FormData();
form.append("file", file);
const res = await fetch("/api/rag/upload", { method: "POST", body: form });
if (!res.ok) throw new Error(JSON.stringify(await res.json().catch(() => res.statusText)));
return res.json();
}
// ββ Local RAG (in-memory, injected into system prompt) ββββββββββββββββββββββββ
export const listLocalDocs = () => _request("/api/local-rag/documents");
export const deleteLocalDoc = (id) => _request(`/api/local-rag/documents/${id}`, { method: "DELETE" });
export async function uploadLocalDoc(file) {
const form = new FormData();
form.append("file", file);
const res = await fetch("/api/local-rag/upload", { method: "POST", body: form });
if (!res.ok) throw new Error(JSON.stringify(await res.json().catch(() => res.statusText)));
return res.json();
}
// ββ Clinical (blood test report) βββββββββββββββββββββββββββββββββββββββββββββββ
export async function uploadClinicalReport(file) {
const form = new FormData();
form.append("file", file);
const res = await fetch("/api/clinical/upload", { method: "POST", body: form });
if (!res.ok) throw new Error(JSON.stringify(await res.json().catch(() => res.statusText)));
return res.json();
}
export const getClinicalReport = () => _request("/api/clinical/current");
export const deleteClinicalReport = () => _request("/api/clinical/current", { method: "DELETE" });
// ββ Telemetry ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
export const endSession = (sessionId) => _post("/api/session/end", { session_id: sessionId });
export const getTelemetrySummary = () => _request("/api/telemetry/summary");
export const getTelemetrySessions = () => _request("/api/telemetry/sessions");
export const resetTelemetry = () => _post("/api/telemetry/reset", {});
|