Sessions: Sidebar, Session-Wechsel, Archivieren-Button, alles session-bezogen
This commit is contained in:
1 parent
8ddee38032
commit
25f07caf83
15 files changed
+442
-78
No files matched your search
+30
-9
@@ -1,31 +1,31 @@
|
||||
// ── API Calls ──
|
||||
|
||||
async function apiChat(model, messages, systemPrompt) {
|
||||
async function apiChat(model, messages, systemPrompt, sessionId) {
|
||||
return fetch('/api/chat', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ model, messages, systemPrompt })
|
||||
body: JSON.stringify({ model, messages, systemPrompt, sessionId })
|
||||
});
|
||||
}
|
||||
|
||||
async function apiHistory(sessionId = 'null') {
|
||||
async function apiHistory(sessionId) {
|
||||
const resp = await fetch(`/api/history?sessionId=${sessionId}`);
|
||||
return resp.json();
|
||||
}
|
||||
|
||||
async function apiHistoryPoll(afterId) {
|
||||
const resp = await fetch(`/api/history/poll?afterId=${afterId}`);
|
||||
async function apiHistoryPoll(sessionId, afterId) {
|
||||
const resp = await fetch(`/api/history/poll?sessionId=${sessionId}&afterId=${afterId}`);
|
||||
return resp.json();
|
||||
}
|
||||
|
||||
async function apiArchive() {
|
||||
const resp = await fetch('/api/archive', { method: 'POST' });
|
||||
async function apiArchive(sessionId) {
|
||||
const resp = await fetch(`/api/archive?sessionId=${sessionId}`, { method: 'POST' });
|
||||
if (resp.status === 204) return null;
|
||||
return resp.json();
|
||||
}
|
||||
|
||||
async function apiListArchives() {
|
||||
const resp = await fetch('/api/archives');
|
||||
async function apiListArchives(sessionId) {
|
||||
const resp = await fetch(`/api/archives?sessionId=${sessionId}`);
|
||||
return resp.json();
|
||||
}
|
||||
|
||||
@@ -33,3 +33,24 @@ async function apiGetArchive(archiveId) {
|
||||
const resp = await fetch(`/api/archive/${archiveId}`);
|
||||
return resp.json();
|
||||
}
|
||||
|
||||
// ── Session API ──
|
||||
|
||||
async function apiGetSessions() {
|
||||
const resp = await fetch('/api/sessions');
|
||||
return resp.json();
|
||||
}
|
||||
|
||||
async function apiCreateSession() {
|
||||
const resp = await fetch('/api/sessions', { method: 'POST' });
|
||||
return resp.json();
|
||||
}
|
||||
|
||||
async function apiUpdateSession(sessionId, data) {
|
||||
const resp = await fetch(`/api/sessions/${sessionId}`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data)
|
||||
});
|
||||
return resp.json();
|
||||
}
|
||||
Reference in new issue
Block a user