implementing model selector

This commit is contained in:
Storme-bit
2026-04-18 01:52:02 -07:00
parent 072758df9c
commit 68f2d758b1
4 changed files with 57 additions and 12 deletions

View File

@@ -1,5 +1,6 @@
const { Router } = require('express');
const settings = require('../config/settings');
const fs = require('fs');
const router = Router();
@@ -32,6 +33,18 @@ router.patch('/', (req, res) => {
updates.scoreThreshold = val;
}
if (req.body.modelsFolderPath !== undefined) {
const val = req.body.modelsFolderPath.trim();
if (!val) return res.status(400).json({ error: 'modelsFolderPath cannot be empty' });
// Verify the path exists and is readable
try {
fs.readdirSync(val);
} catch {
return res.status(400).json({ error: `Path not accessible: ${val}` });
}
updates.modelsFolderPath = val;
}
res.json(settings.save(updates));
});