Add language assistant settings and related features: Introduce new routes and controller methods for managing language assistant settings, including retrieval and saving of LLM configurations. Update navigation structure to include language assistant options. Enhance vocab course model to support additional learning attributes such as learning goals and core patterns. Update SQL scripts to reflect new database schema changes for vocab courses. Improve localization for language assistant settings in German and English.
This commit is contained in:
@@ -214,6 +214,10 @@ const menuStructure = {
|
||||
visible: ["all"],
|
||||
path: "/settings/account"
|
||||
},
|
||||
languageAssistant: {
|
||||
visible: ["all"],
|
||||
path: "/settings/language-assistant"
|
||||
},
|
||||
personal: {
|
||||
visible: ["all"],
|
||||
path: "/settings/personal"
|
||||
|
||||
@@ -185,6 +185,38 @@ class SettingsController {
|
||||
res.status(500).json({ error: 'Internal server error' });
|
||||
}
|
||||
}
|
||||
|
||||
async getLlmSettings(req, res) {
|
||||
try {
|
||||
const hashedUserId = req.headers.userid;
|
||||
const data = await settingsService.getLlmSettings(hashedUserId);
|
||||
res.status(200).json(data);
|
||||
} catch (error) {
|
||||
console.error('Error retrieving LLM settings:', error);
|
||||
res.status(500).json({ error: 'Internal server error' });
|
||||
}
|
||||
}
|
||||
|
||||
async saveLlmSettings(req, res) {
|
||||
const schema = Joi.object({
|
||||
baseUrl: Joi.string().allow('').optional(),
|
||||
model: Joi.string().allow('').optional(),
|
||||
enabled: Joi.boolean().optional(),
|
||||
apiKey: Joi.string().allow('').optional(),
|
||||
clearKey: Joi.boolean().optional()
|
||||
});
|
||||
const { error, value } = schema.validate(req.body || {});
|
||||
if (error) {
|
||||
return res.status(400).json({ error: error.details[0].message });
|
||||
}
|
||||
try {
|
||||
await settingsService.saveLlmSettings(req.headers.userid, value);
|
||||
res.status(200).json({ success: true });
|
||||
} catch (err) {
|
||||
console.error('Error saving LLM settings:', err);
|
||||
res.status(500).json({ error: 'Internal server error' });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default SettingsController;
|
||||
|
||||
Reference in New Issue
Block a user