mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
⚙️ fix: minor issues related to agents (#4297)
* chore: deprecate `web-browser` tool * fix: edit agent permission
This commit is contained in:
parent
2ce8647540
commit
2ca257dfb9
2 changed files with 15 additions and 24 deletions
|
|
@ -1,9 +1,7 @@
|
||||||
const { Tools } = require('librechat-data-provider');
|
const { Tools } = require('librechat-data-provider');
|
||||||
const { ZapierToolKit } = require('langchain/agents');
|
const { ZapierToolKit } = require('langchain/agents');
|
||||||
const { Calculator } = require('langchain/tools/calculator');
|
const { Calculator } = require('langchain/tools/calculator');
|
||||||
const { WebBrowser } = require('langchain/tools/webbrowser');
|
|
||||||
const { SerpAPI, ZapierNLAWrapper } = require('langchain/tools');
|
const { SerpAPI, ZapierNLAWrapper } = require('langchain/tools');
|
||||||
const { OpenAIEmbeddings } = require('langchain/embeddings/openai');
|
|
||||||
const { createCodeExecutionTool, EnvVar } = require('@librechat/agents');
|
const { createCodeExecutionTool, EnvVar } = require('@librechat/agents');
|
||||||
const { getUserPluginAuthValue } = require('~/server/services/PluginService');
|
const { getUserPluginAuthValue } = require('~/server/services/PluginService');
|
||||||
const {
|
const {
|
||||||
|
|
@ -31,12 +29,6 @@ const { loadToolSuite } = require('./loadToolSuite');
|
||||||
const { loadSpecs } = require('./loadSpecs');
|
const { loadSpecs } = require('./loadSpecs');
|
||||||
const { logger } = require('~/config');
|
const { logger } = require('~/config');
|
||||||
|
|
||||||
const getOpenAIKey = async (options, user) => {
|
|
||||||
let openAIApiKey = options.openAIApiKey ?? process.env.OPENAI_API_KEY;
|
|
||||||
openAIApiKey = openAIApiKey === 'user_provided' ? null : openAIApiKey;
|
|
||||||
return openAIApiKey || (await getUserPluginAuthValue(user, 'OPENAI_API_KEY'));
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates the availability and authentication of tools for a user based on environment variables or user-specific plugin authentication values.
|
* Validates the availability and authentication of tools for a user based on environment variables or user-specific plugin authentication values.
|
||||||
* Tools without required authentication or with valid authentication are considered valid.
|
* Tools without required authentication or with valid authentication are considered valid.
|
||||||
|
|
@ -177,8 +169,6 @@ const loadTools = async ({
|
||||||
traversaal_search: TraversaalSearch,
|
traversaal_search: TraversaalSearch,
|
||||||
};
|
};
|
||||||
|
|
||||||
const openAIApiKey = await getOpenAIKey(options, user);
|
|
||||||
|
|
||||||
const customConstructors = {
|
const customConstructors = {
|
||||||
e2b_code_interpreter: async () => {
|
e2b_code_interpreter: async () => {
|
||||||
if (!functions) {
|
if (!functions) {
|
||||||
|
|
@ -191,7 +181,6 @@ const loadTools = async ({
|
||||||
user,
|
user,
|
||||||
options: {
|
options: {
|
||||||
model,
|
model,
|
||||||
openAIApiKey,
|
|
||||||
...options,
|
...options,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -208,14 +197,6 @@ const loadTools = async ({
|
||||||
options,
|
options,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
'web-browser': async () => {
|
|
||||||
// let openAIApiKey = options.openAIApiKey ?? process.env.OPENAI_API_KEY;
|
|
||||||
// openAIApiKey = openAIApiKey === 'user_provided' ? null : openAIApiKey;
|
|
||||||
// openAIApiKey = openAIApiKey || (await getUserPluginAuthValue(user, 'OPENAI_API_KEY'));
|
|
||||||
const browser = new WebBrowser({ model, embeddings: new OpenAIEmbeddings({ openAIApiKey }) });
|
|
||||||
browser.description_for_model = browser.description;
|
|
||||||
return browser;
|
|
||||||
},
|
|
||||||
serpapi: async () => {
|
serpapi: async () => {
|
||||||
let apiKey = process.env.SERPAPI_API_KEY;
|
let apiKey = process.env.SERPAPI_API_KEY;
|
||||||
if (!apiKey) {
|
if (!apiKey) {
|
||||||
|
|
|
||||||
|
|
@ -174,15 +174,25 @@ export default function AgentPanel({
|
||||||
}
|
}
|
||||||
}, [agent_id, onSelectAgent]);
|
}, [agent_id, onSelectAgent]);
|
||||||
|
|
||||||
|
const canEditAgent = useMemo(() => {
|
||||||
|
const canEdit =
|
||||||
|
agentQuery.data?.isCollaborative ?? false
|
||||||
|
? true
|
||||||
|
: agentQuery.data?.author === user?.id || user?.role === SystemRoles.ADMIN;
|
||||||
|
|
||||||
|
return agentQuery.data?.id != null && agentQuery.data.id ? canEdit : true;
|
||||||
|
}, [
|
||||||
|
agentQuery.data?.isCollaborative,
|
||||||
|
agentQuery.data?.author,
|
||||||
|
agentQuery.data?.id,
|
||||||
|
user?.id,
|
||||||
|
user?.role,
|
||||||
|
]);
|
||||||
|
|
||||||
if (agentQuery.isInitialLoading) {
|
if (agentQuery.isInitialLoading) {
|
||||||
return <AgentPanelSkeleton />;
|
return <AgentPanelSkeleton />;
|
||||||
}
|
}
|
||||||
|
|
||||||
const canEditAgent =
|
|
||||||
agentQuery.data?.isCollaborative ?? false
|
|
||||||
? true
|
|
||||||
: agentQuery.data?.author === user?.id || user?.role === SystemRoles.ADMIN;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormProvider {...methods}>
|
<FormProvider {...methods}>
|
||||||
<form
|
<form
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue