mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +01:00
🔄 refactor: OAI Image Edit Proxy, Speech Settings Handling, Import Query Data Usage (#10281)
Some checks failed
Docker Dev Branch Images Build / build (Dockerfile, lc-dev, node) (push) Has been cancelled
Docker Dev Branch Images Build / build (Dockerfile.multi, lc-dev-api, api-build) (push) Has been cancelled
Docker Dev Images Build / build (Dockerfile, librechat-dev, node) (push) Has been cancelled
Docker Dev Images Build / build (Dockerfile.multi, librechat-dev-api, api-build) (push) Has been cancelled
Sync Locize Translations & Create Translation PR / Sync Translation Keys with Locize (push) Has been cancelled
Sync Locize Translations & Create Translation PR / Create Translation PR on Version Published (push) Has been cancelled
Some checks failed
Docker Dev Branch Images Build / build (Dockerfile, lc-dev, node) (push) Has been cancelled
Docker Dev Branch Images Build / build (Dockerfile.multi, lc-dev-api, api-build) (push) Has been cancelled
Docker Dev Images Build / build (Dockerfile, librechat-dev, node) (push) Has been cancelled
Docker Dev Images Build / build (Dockerfile.multi, librechat-dev-api, api-build) (push) Has been cancelled
Sync Locize Translations & Create Translation PR / Sync Translation Keys with Locize (push) Has been cancelled
Sync Locize Translations & Create Translation PR / Create Translation PR on Version Published (push) Has been cancelled
* chore: correct startupConfig usage in ImportConversations component * refactor: properly process configured speechToText and textToSpeech settings in getCustomConfigSpeech * refactor: proxy configuration by utilizing HttpsProxyAgent for OpenAI Image Edits
This commit is contained in:
parent
250209858a
commit
0e05ff484f
3 changed files with 23 additions and 24 deletions
|
|
@ -5,6 +5,7 @@ const FormData = require('form-data');
|
||||||
const { ProxyAgent } = require('undici');
|
const { ProxyAgent } = require('undici');
|
||||||
const { tool } = require('@langchain/core/tools');
|
const { tool } = require('@langchain/core/tools');
|
||||||
const { logger } = require('@librechat/data-schemas');
|
const { logger } = require('@librechat/data-schemas');
|
||||||
|
const { HttpsProxyAgent } = require('https-proxy-agent');
|
||||||
const { logAxiosError, oaiToolkit } = require('@librechat/api');
|
const { logAxiosError, oaiToolkit } = require('@librechat/api');
|
||||||
const { ContentTypes, EImageOutputType } = require('librechat-data-provider');
|
const { ContentTypes, EImageOutputType } = require('librechat-data-provider');
|
||||||
const { getStrategyFunctions } = require('~/server/services/Files/strategies');
|
const { getStrategyFunctions } = require('~/server/services/Files/strategies');
|
||||||
|
|
@ -348,16 +349,7 @@ Error Message: ${error.message}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (process.env.PROXY) {
|
if (process.env.PROXY) {
|
||||||
try {
|
axiosConfig.httpsAgent = new HttpsProxyAgent(process.env.PROXY);
|
||||||
const url = new URL(process.env.PROXY);
|
|
||||||
axiosConfig.proxy = {
|
|
||||||
host: url.hostname.replace(/^\[|\]$/g, ''),
|
|
||||||
port: url.port ? parseInt(url.port, 10) : undefined,
|
|
||||||
protocol: url.protocol.replace(':', ''),
|
|
||||||
};
|
|
||||||
} catch (error) {
|
|
||||||
logger.error('Error parsing proxy URL:', error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.env.IMAGE_GEN_OAI_AZURE_API_VERSION && process.env.IMAGE_GEN_OAI_BASEURL) {
|
if (process.env.IMAGE_GEN_OAI_AZURE_API_VERSION && process.env.IMAGE_GEN_OAI_BASEURL) {
|
||||||
|
|
|
||||||
|
|
@ -42,18 +42,26 @@ async function getCustomConfigSpeech(req, res) {
|
||||||
settings.advancedMode = speechTab.advancedMode;
|
settings.advancedMode = speechTab.advancedMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (speechTab.speechToText) {
|
if (speechTab.speechToText !== undefined) {
|
||||||
for (const key in speechTab.speechToText) {
|
if (typeof speechTab.speechToText === 'boolean') {
|
||||||
if (speechTab.speechToText[key] !== undefined) {
|
settings.speechToText = speechTab.speechToText;
|
||||||
settings[key] = speechTab.speechToText[key];
|
} else {
|
||||||
|
for (const key in speechTab.speechToText) {
|
||||||
|
if (speechTab.speechToText[key] !== undefined) {
|
||||||
|
settings[key] = speechTab.speechToText[key];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (speechTab.textToSpeech) {
|
if (speechTab.textToSpeech !== undefined) {
|
||||||
for (const key in speechTab.textToSpeech) {
|
if (typeof speechTab.textToSpeech === 'boolean') {
|
||||||
if (speechTab.textToSpeech[key] !== undefined) {
|
settings.textToSpeech = speechTab.textToSpeech;
|
||||||
settings[key] = speechTab.textToSpeech[key];
|
} else {
|
||||||
|
for (const key in speechTab.textToSpeech) {
|
||||||
|
if (speechTab.textToSpeech[key] !== undefined) {
|
||||||
|
settings[key] = speechTab.textToSpeech[key];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,10 @@ import { useLocalize } from '~/hooks';
|
||||||
import { cn, logger } from '~/utils';
|
import { cn, logger } from '~/utils';
|
||||||
|
|
||||||
function ImportConversations() {
|
function ImportConversations() {
|
||||||
const queryClient = useQueryClient();
|
|
||||||
const startupConfig = queryClient.getQueryData<TStartupConfig>([QueryKeys.startupConfig]);
|
|
||||||
const localize = useLocalize();
|
const localize = useLocalize();
|
||||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
const queryClient = useQueryClient();
|
||||||
const { showToast } = useToastContext();
|
const { showToast } = useToastContext();
|
||||||
|
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||||
const [isUploading, setIsUploading] = useState(false);
|
const [isUploading, setIsUploading] = useState(false);
|
||||||
|
|
||||||
const handleSuccess = useCallback(() => {
|
const handleSuccess = useCallback(() => {
|
||||||
|
|
@ -53,7 +51,8 @@ function ImportConversations() {
|
||||||
const handleFileUpload = useCallback(
|
const handleFileUpload = useCallback(
|
||||||
async (file: File) => {
|
async (file: File) => {
|
||||||
try {
|
try {
|
||||||
const maxFileSize = (startupConfig as any)?.conversationImportMaxFileSize;
|
const startupConfig = queryClient.getQueryData<TStartupConfig>([QueryKeys.startupConfig]);
|
||||||
|
const maxFileSize = startupConfig?.conversationImportMaxFileSize;
|
||||||
if (maxFileSize && file.size > maxFileSize) {
|
if (maxFileSize && file.size > maxFileSize) {
|
||||||
const size = (maxFileSize / (1024 * 1024)).toFixed(2);
|
const size = (maxFileSize / (1024 * 1024)).toFixed(2);
|
||||||
showToast({
|
showToast({
|
||||||
|
|
@ -76,7 +75,7 @@ function ImportConversations() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[uploadFile, showToast, localize, startupConfig],
|
[uploadFile, showToast, localize, queryClient],
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleFileChange = useCallback(
|
const handleFileChange = useCallback(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue