mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
fix(handleTools.js): refactor loading of openAIApiKey to handle user_provided value (#603)
fix(PluginController.js): handle user_provided value in isPluginAuthenticated function refactor(PluginService.js): remove commented out code
This commit is contained in:
parent
9eefa3e24c
commit
a64342f515
3 changed files with 6 additions and 5 deletions
|
|
@ -84,10 +84,9 @@ const loadTools = async ({ user, model, functions = null, tools = [], options =
|
||||||
|
|
||||||
const customConstructors = {
|
const customConstructors = {
|
||||||
browser: async () => {
|
browser: async () => {
|
||||||
let openAIApiKey = process.env.OPENAI_API_KEY;
|
let openAIApiKey = options.openAIApiKey ?? process.env.OPENAI_API_KEY;
|
||||||
if (!openAIApiKey) {
|
openAIApiKey = openAIApiKey === 'user_provided' ? null : openAIApiKey;
|
||||||
openAIApiKey = await getUserPluginAuthValue(user, 'OPENAI_API_KEY');
|
openAIApiKey = openAIApiKey || await getUserPluginAuthValue(user, 'OPENAI_API_KEY');
|
||||||
}
|
|
||||||
return new WebBrowser({ model, embeddings: new OpenAIEmbeddings({ openAIApiKey }) });
|
return new WebBrowser({ model, embeddings: new OpenAIEmbeddings({ openAIApiKey }) });
|
||||||
},
|
},
|
||||||
serpapi: async () => {
|
serpapi: async () => {
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,9 @@ const isPluginAuthenticated = (plugin) => {
|
||||||
|
|
||||||
return plugin.authConfig.every((authFieldObj) => {
|
return plugin.authConfig.every((authFieldObj) => {
|
||||||
const envValue = process.env[authFieldObj.authField];
|
const envValue = process.env[authFieldObj.authField];
|
||||||
|
if (envValue === 'user_provided') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return envValue && envValue.trim() !== '';
|
return envValue && envValue.trim() !== '';
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@ const getUserPluginAuthValue = async (user, authField) => {
|
||||||
// }
|
// }
|
||||||
// };
|
// };
|
||||||
|
|
||||||
|
|
||||||
const updateUserPluginAuth = async (userId, authField, pluginKey, value) => {
|
const updateUserPluginAuth = async (userId, authField, pluginKey, value) => {
|
||||||
try {
|
try {
|
||||||
const encryptedValue = encrypt(value);
|
const encryptedValue = encrypt(value);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue