Files
gott/wwwroot/js/api.js
T

20 lines
556 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', limit = 50) {
const resp = await fetch(`/api/history?sessionId=${sessionId}&limit=${limit}`);
return resp.json();
}
async function apiHistoryPoll(afterId) {
const resp = await fetch(`/api/history/poll?afterId=${afterId}`);
return resp.json();
}