Files
gott/wwwroot/js/api.js
T

36 lines
917 B
JavaScript

// ── API Calls ──
async function apiChat(model, messages, systemPrompt) {
return fetch('/api/chat', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ model, messages, systemPrompt })
});
}
async function apiHistory(sessionId = 'null') {
const resp = await fetch(`/api/history?sessionId=${sessionId}`);
return resp.json();
}
async function apiHistoryPoll(afterId) {
const resp = await fetch(`/api/history/poll?afterId=${afterId}`);
return resp.json();
}
async function apiArchive() {
const resp = await fetch('/api/archive', { method: 'POST' });
if (resp.status === 204) return null;
return resp.json();
}
async function apiListArchives() {
const resp = await fetch('/api/archives');
return resp.json();
}
async function apiGetArchive(archiveId) {
const resp = await fetch(`/api/archive/${archiveId}`);
return resp.json();
}