mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-22 06:00:56 +02:00
🔧 fix: handle missing custom config speech (#3790)
* feat: Update speech settings retrieval logic to handle missing custom configuration This commit updates the logic in the Speech component and the getCustomConfigSpeech function to handle the case where the custom configuration is missing. Previously, if no custom configuration was found, an error would occur. Now, the code checks for the presence of the custom configuration and returns a message indicating that no custom configuration was found. This improves the robustness of the application and provides a better user experience. * refactor: changed response message when no custom config is found
This commit is contained in:
parent
34fd960d54
commit
62881fee54
2 changed files with 11 additions and 3 deletions
|
@ -1,4 +1,5 @@
|
||||||
const getCustomConfig = require('~/server/services/Config/getCustomConfig');
|
const getCustomConfig = require('~/server/services/Config/getCustomConfig');
|
||||||
|
const { logger } = require('~/config');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function retrieves the speechTab settings from the custom configuration
|
* This function retrieves the speechTab settings from the custom configuration
|
||||||
|
@ -15,6 +16,13 @@ const getCustomConfig = require('~/server/services/Config/getCustomConfig');
|
||||||
async function getCustomConfigSpeech(req, res) {
|
async function getCustomConfigSpeech(req, res) {
|
||||||
try {
|
try {
|
||||||
const customConfig = await getCustomConfig();
|
const customConfig = await getCustomConfig();
|
||||||
|
|
||||||
|
if (!customConfig) {
|
||||||
|
return res.status(200).send({
|
||||||
|
message: 'not_found',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const sttExternal = !!customConfig.speech?.stt;
|
const sttExternal = !!customConfig.speech?.stt;
|
||||||
const ttsExternal = !!customConfig.speech?.tts;
|
const ttsExternal = !!customConfig.speech?.tts;
|
||||||
let settings = {
|
let settings = {
|
||||||
|
@ -22,7 +30,7 @@ async function getCustomConfigSpeech(req, res) {
|
||||||
ttsExternal,
|
ttsExternal,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!customConfig || !customConfig.speech?.speechTab) {
|
if (!customConfig.speech?.speechTab) {
|
||||||
return res.status(200).send(settings);
|
return res.status(200).send(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +58,7 @@ async function getCustomConfigSpeech(req, res) {
|
||||||
|
|
||||||
return res.status(200).send(settings);
|
return res.status(200).send(settings);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to get custom config speech settings:', error);
|
logger.error('Failed to get custom config speech settings:', error);
|
||||||
res.status(500).send('Internal Server Error');
|
res.status(500).send('Internal Server Error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ function Speech() {
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data) {
|
if (data && data.message !== 'not_found') {
|
||||||
Object.entries(data).forEach(([key, value]) => {
|
Object.entries(data).forEach(([key, value]) => {
|
||||||
updateSetting(key, value);
|
updateSetting(key, value);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue