bulk episodic deletion
This commit is contained in:
@@ -13,6 +13,7 @@ export default defineConfig({
|
||||
'/sessions': 'http://192.168.0.205:4000',
|
||||
'/models': 'http://192.168.0.205:4000',
|
||||
'/projects': 'http://192.168.0.205:4000',
|
||||
'/episodes': 'http://192.168.0.205:4000',
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -1,10 +1,14 @@
|
||||
require ('dotenv').config();
|
||||
const express = require('express');
|
||||
const {getEnv, PORTS, SERVICES, ORCHESTRATION} = require('@nexusai/shared');
|
||||
|
||||
/**** ROUTERS *** */
|
||||
const chatRouter = require('./routes/chat');
|
||||
const sessionsRouter = require('./routes/sessions');
|
||||
const modelsRouter = require('./routes/models');
|
||||
const projectsRouter = require('./routes/projects');
|
||||
const episodesRouter = require('./routes/episodes')
|
||||
|
||||
const cors = require('cors');
|
||||
|
||||
const app = express();
|
||||
@@ -39,6 +43,7 @@ app.use('/chat', chatRouter);
|
||||
app.use('/sessions', sessionsRouter);
|
||||
app.use('/models', modelsRouter);
|
||||
app.use('/projects', projectsRouter);
|
||||
app.use('/episodes', episodesRouter)
|
||||
|
||||
/******* Start the server ************/
|
||||
app.listen(PORT, () => {
|
||||
|
||||
25
packages/orchestration-service/src/routes/episodes.js
Normal file
25
packages/orchestration-service/src/routes/episodes.js
Normal file
@@ -0,0 +1,25 @@
|
||||
const { Router } = require('express');
|
||||
const memory = require('../services/memory');
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.get('/', async (req, res) => {
|
||||
const { limit, offset, sessionId, q } = req.query;
|
||||
try {
|
||||
const result = await memory.getEpisodes({ limit, offset, sessionId, q });
|
||||
res.json(result);
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
router.delete('/:id', async (req, res) => {
|
||||
try {
|
||||
await memory.deleteEpisode(req.params.id);
|
||||
res.status(204).send();
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
@@ -133,6 +133,23 @@ async function getProject(id) {
|
||||
return res.json();
|
||||
}
|
||||
|
||||
async function getEpisodes({ limit = 50, offset = 0, sessionId, q } = {}) {
|
||||
const url = new URL(`${BASE_URL}/episodes`);
|
||||
url.searchParams.set('limit', limit);
|
||||
url.searchParams.set('offset', offset);
|
||||
if (sessionId) url.searchParams.set('sessionId', sessionId);
|
||||
if (q) url.searchParams.set('q', q);
|
||||
|
||||
const res = await fetch(url.toString());
|
||||
if (!res.ok) throw new Error(`Failed to fetch episodes: ${res.status}`);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
async function deleteEpisode(id) {
|
||||
const res = await fetch(`${BASE_URL}/episodes/${id}`, { method: 'DELETE' });
|
||||
if (!res.ok) throw new Error(`Failed to delete episode: ${res.status}`);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getSessionByExternalId,
|
||||
createSession,
|
||||
@@ -149,4 +166,6 @@ module.exports = {
|
||||
deleteProject,
|
||||
getProjectSessions,
|
||||
getProject,
|
||||
getEpisodes,
|
||||
deleteEpisode,
|
||||
}
|
||||
Reference in New Issue
Block a user