Vaibhav Kathait
Add en/it/fr/es/de language support; default to our own agent LLM instead of Anam's
7f73287 Download anam/static/js/api.js from SUPER321/anam_code: direct link, hf CLI and curl.
- Browser
- Download file 3.49 kB
-
https://huggingface.co/spaces/SUPER321/anam_code/resolve/main/anam/static/js/api.js
- Command line
-
hf download hf://spaces/SUPER321/anam_code/anam/static/js/api.js
-
curl -L -o api.js https://huggingface.co/spaces/SUPER321/anam_code/resolve/main/anam/static/js/api.js
3.49 kB
| 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", {}); | |