Skip to content

Commit 4679c0c

Browse files
authored
Merge pull request #121 from PytorchConnectomics/feature/chat-on-demand
Feature/chat on demand
2 parents ff87df2 + 006a779 commit 4679c0c

9 files changed

Lines changed: 1507 additions & 230 deletions

File tree

client/src/api.js

Lines changed: 75 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,13 @@ export async function stopModelInference() {
331331
}
332332
}
333333

334-
export async function queryChatBot(query) {
334+
export async function queryChatBot(query, conversationId) {
335335
try {
336-
const res = await axios.post(`${BASE_URL}/chat/query`, { query });
337-
return res.data?.response;
336+
const res = await axios.post(`${BASE_URL}/chat/query`, {
337+
query,
338+
conversationId,
339+
});
340+
return res.data;
338341
} catch (error) {
339342
handleError(error);
340343
}
@@ -348,6 +351,75 @@ export async function clearChat() {
348351
}
349352
}
350353

354+
// ── Conversation history endpoints ───────────────────────────────────────────
355+
356+
export async function listConversations() {
357+
try {
358+
const res = await axios.get(`${BASE_URL}/chat/conversations`);
359+
return res.data;
360+
} catch (error) {
361+
handleError(error);
362+
}
363+
}
364+
365+
export async function createConversation() {
366+
try {
367+
const res = await axios.post(`${BASE_URL}/chat/conversations`);
368+
return res.data;
369+
} catch (error) {
370+
handleError(error);
371+
}
372+
}
373+
374+
export async function getConversation(convoId) {
375+
try {
376+
const res = await axios.get(`${BASE_URL}/chat/conversations/${convoId}`);
377+
return res.data;
378+
} catch (error) {
379+
handleError(error);
380+
}
381+
}
382+
383+
export async function deleteConversation(convoId) {
384+
try {
385+
await axios.delete(`${BASE_URL}/chat/conversations/${convoId}`);
386+
} catch (error) {
387+
handleError(error);
388+
}
389+
}
390+
391+
export async function updateConversationTitle(convoId, title) {
392+
try {
393+
const res = await axios.patch(`${BASE_URL}/chat/conversations/${convoId}`, {
394+
title,
395+
});
396+
return res.data;
397+
} catch (error) {
398+
handleError(error);
399+
}
400+
}
401+
402+
export async function queryHelperChat(taskKey, query, fieldContext) {
403+
try {
404+
const res = await axios.post(`${BASE_URL}/chat/helper/query`, {
405+
taskKey,
406+
query,
407+
fieldContext,
408+
});
409+
return res.data?.response;
410+
} catch (error) {
411+
handleError(error);
412+
}
413+
}
414+
415+
export async function clearHelperChat(taskKey) {
416+
try {
417+
await axios.post(`${BASE_URL}/chat/helper/clear`, { taskKey });
418+
} catch (error) {
419+
handleError(error);
420+
}
421+
}
422+
351423
export async function getConfigPresets() {
352424
return makeApiRequest("pytc/configs", "get");
353425
}

0 commit comments

Comments
 (0)