model temperature settings
This commit is contained in:
@@ -34,16 +34,23 @@ router.patch('/', (req, res) => {
|
||||
}
|
||||
|
||||
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}` });
|
||||
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;
|
||||
}
|
||||
|
||||
if (req.body.temperature !== undefined) {
|
||||
const val = Number(req.body.temperature);
|
||||
if (isNaN(val) || val < 0 || val > 2)
|
||||
return res.status(400).json({ error: 'temperature must be 0–2' });
|
||||
updates.temperature = val;
|
||||
}
|
||||
updates.modelsFolderPath = val;
|
||||
}
|
||||
|
||||
res.json(settings.save(updates));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user