* wip agent builder * refactor structure for agent builder * improve ui for add block menu and sidebar * lint * node ui improvement * handle deleting variable in all nodes * add headers and body to apiCall node * lint * Agent flow builder backend (#3078) * wip agent builder backend * save/load agent tasks * lint * refactor agent task to use uuids instead of names * placeholder for run task * update frontend sidebar + seperate backend to agent-tasks utils * lint * add deleting of agent tasks * create AgentTasks class + wip load agent tasks into aibitat * lint * inject + call agent tasks * wip call agent tasks * add llm instruction + fix api calling blocks * add ui + backend for editing/toggling agent tasks * lint * add back middlewares * disable run task + add navigate to home on logo click * implement normalizePath to prevent path traversal * wip make api calling more consistent * lint * rename all references from task to flow * patch load flow bug when on editing page * remove unneeded files/comments * lint * fix delete endpoint + rename load flows * add move block to ui + fix api-call backend + add telemetry * lint * add web scraping block * only allow admin for agent builder --------- Co-authored-by: timothycarambat <rambat1010@gmail.com> * Move AgentFlowManager flows to static simplify UI states Handle LLM prompt flow when provided non-string * delete/edit menu for agent flow panel + update flow icon * lint * fix open builder button hidden bug * add tooltips to move up/down block buttons * add tooltip to delete block * truncate block description to fit on blocklist component * light mode agent builder sidebar * light mode api call block * fix light mode styles for agent builder blocks * agent flow fetch in UI * sync delete flow * agent flow ui/ux improvements * remove unused AgentSidebar component * comment out /run * UI changes and updates for flow builder * format flow panel info * update link handling * ui tweaks to header menu * remove unused import * update doc links update block icons * bump readme * Patch code block header oddity resolves #3117 * bump dev image --------- Co-authored-by: Timothy Carambat <rambat1010@gmail.com>
93 lines
2.6 KiB
JavaScript
93 lines
2.6 KiB
JavaScript
const AgentPlugins = require("./aibitat/plugins");
|
|
const { SystemSettings } = require("../../models/systemSettings");
|
|
const { safeJsonParse } = require("../http");
|
|
const Provider = require("./aibitat/providers/ai-provider");
|
|
const ImportedPlugin = require("./imported");
|
|
const { AgentFlows } = require("../agentFlows");
|
|
|
|
// This is a list of skills that are built-in and default enabled.
|
|
const DEFAULT_SKILLS = [
|
|
AgentPlugins.memory.name,
|
|
AgentPlugins.docSummarizer.name,
|
|
AgentPlugins.webScraping.name,
|
|
];
|
|
|
|
const USER_AGENT = {
|
|
name: "USER",
|
|
getDefinition: async () => {
|
|
return {
|
|
interrupt: "ALWAYS",
|
|
role: "I am the human monitor and oversee this chat. Any questions on action or decision making should be directed to me.",
|
|
};
|
|
},
|
|
};
|
|
|
|
const WORKSPACE_AGENT = {
|
|
name: "@agent",
|
|
getDefinition: async (provider = null) => {
|
|
return {
|
|
role: Provider.systemPrompt(provider),
|
|
functions: [
|
|
...(await agentSkillsFromSystemSettings()),
|
|
...ImportedPlugin.activeImportedPlugins(),
|
|
...AgentFlows.activeFlowPlugins(),
|
|
],
|
|
};
|
|
},
|
|
};
|
|
|
|
/**
|
|
* Fetches and preloads the names/identifiers for plugins that will be dynamically
|
|
* loaded later
|
|
* @returns {Promise<string[]>}
|
|
*/
|
|
async function agentSkillsFromSystemSettings() {
|
|
const systemFunctions = [];
|
|
|
|
// Load non-imported built-in skills that are configurable, but are default enabled.
|
|
const _disabledDefaultSkills = safeJsonParse(
|
|
await SystemSettings.getValueOrFallback(
|
|
{ label: "disabled_agent_skills" },
|
|
"[]"
|
|
),
|
|
[]
|
|
);
|
|
DEFAULT_SKILLS.forEach((skill) => {
|
|
if (!_disabledDefaultSkills.includes(skill))
|
|
systemFunctions.push(AgentPlugins[skill].name);
|
|
});
|
|
|
|
// Load non-imported built-in skills that are configurable.
|
|
const _setting = safeJsonParse(
|
|
await SystemSettings.getValueOrFallback(
|
|
{ label: "default_agent_skills" },
|
|
"[]"
|
|
),
|
|
[]
|
|
);
|
|
_setting.forEach((skillName) => {
|
|
if (!AgentPlugins.hasOwnProperty(skillName)) return;
|
|
|
|
// This is a plugin module with many sub-children plugins who
|
|
// need to be named via `${parent}#${child}` naming convention
|
|
if (Array.isArray(AgentPlugins[skillName].plugin)) {
|
|
for (const subPlugin of AgentPlugins[skillName].plugin) {
|
|
systemFunctions.push(
|
|
`${AgentPlugins[skillName].name}#${subPlugin.name}`
|
|
);
|
|
}
|
|
return;
|
|
}
|
|
|
|
// This is normal single-stage plugin
|
|
systemFunctions.push(AgentPlugins[skillName].name);
|
|
});
|
|
return systemFunctions;
|
|
}
|
|
|
|
module.exports = {
|
|
USER_AGENT,
|
|
WORKSPACE_AGENT,
|
|
agentSkillsFromSystemSettings,
|
|
};
|