chat client clean up and switch to llama.cpp with models folder network sharing
This commit is contained in:
@@ -36,10 +36,14 @@ router.post('/stream', async (req, res) => {
|
||||
res.flushHeaders();
|
||||
|
||||
try {
|
||||
await chatStream(sessionId, message, (delta) => {
|
||||
res.write(`data: ${JSON.stringify({ text: delta})}\n\n`)
|
||||
})
|
||||
res.write(`data: ${JSON.stringify({done: true})}\n\n`);
|
||||
const { model, tokenCount } = await chatStream(
|
||||
sessionId,
|
||||
message,
|
||||
(delta) => { res.write(`data: ${JSON.stringify({ text: delta })}\n\n`) },
|
||||
{ model: req.body.model, temperature: req.body.temperature }
|
||||
);
|
||||
|
||||
res.write(`data: ${JSON.stringify({ done: true, model, tokenCount })}\n\n`);
|
||||
} catch (err) {
|
||||
res.write(`data: ${JSON.stringify({error: err.message})}\n\n`);
|
||||
} finally {
|
||||
|
||||
21
packages/orchestration-service/src/routes/models.js
Normal file
21
packages/orchestration-service/src/routes/models.js
Normal file
@@ -0,0 +1,21 @@
|
||||
// routes/models.js
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const {getEnv} = require('@nexusai/shared');
|
||||
|
||||
const MODELS_PATH = getEnv('MODELS_MANIFEST_PATH', path.join(__dirname, '../models.json'));
|
||||
|
||||
router.get('/', (req, res) => {
|
||||
try {
|
||||
const raw = fs.readFileSync(MODELS_PATH, 'utf8');
|
||||
const models = JSON.parse(raw);
|
||||
res.json(models);
|
||||
} catch (err) {
|
||||
console.error('[models] Failed to read manifest:', err.message);
|
||||
res.status(500).json({ error: 'Could not load models manifest' });
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
Reference in New Issue
Block a user