Agents: CRUD, DB table, session binding, replace model picker
- agents table with name, avatar, description, model, persona, instructions, soft-delete - AgentEndpoint (GET/POST/PUT/DELETE /api/agents) - sessions + chains now reference agent_id - ChatEndpoint resolves agent from session (no agent = no chat) - system prompt built from agent persona + instructions - frontend: agent editor with avatar upload, agent cards on dashboard - session: agent dropdown replaces model picker, choice persisted
This commit is contained in:
1 parent
0cd2d51d32
commit
449c872296
16 files changed
+552
-46
No files matched your search
+37
-2
@@ -1,13 +1,48 @@
|
||||
// ── API Calls ──
|
||||
|
||||
async function apiChat(model, messages, systemPrompt, sessionId) {
|
||||
async function apiChat(messages, systemPrompt, sessionId) {
|
||||
return fetch('/api/chat', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ model, messages, systemPrompt, sessionId })
|
||||
body: JSON.stringify({ messages, systemPrompt, sessionId })
|
||||
});
|
||||
}
|
||||
|
||||
// ── Agent API ──
|
||||
|
||||
async function apiGetAgents() {
|
||||
const resp = await fetch('/api/agents');
|
||||
return resp.json();
|
||||
}
|
||||
|
||||
async function apiGetAgent(agentId) {
|
||||
const resp = await fetch(`/api/agents/${agentId}`);
|
||||
if (!resp.ok) return null;
|
||||
return resp.json();
|
||||
}
|
||||
|
||||
async function apiCreateAgent(data) {
|
||||
const resp = await fetch('/api/agents', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data)
|
||||
});
|
||||
return resp.json();
|
||||
}
|
||||
|
||||
async function apiUpdateAgent(agentId, data) {
|
||||
const resp = await fetch(`/api/agents/${agentId}`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data)
|
||||
});
|
||||
return resp.json();
|
||||
}
|
||||
|
||||
async function apiDeleteAgent(agentId) {
|
||||
return fetch(`/api/agents/${agentId}`, { method: 'DELETE' });
|
||||
}
|
||||
|
||||
async function apiHistory(sessionId) {
|
||||
const resp = await fetch(`/api/history?sessionId=${sessionId}`);
|
||||
return resp.json();
|
||||
|
||||
Reference in new issue
Block a user