diff --git a/gui/pages/Content/Agents/AgentCreate.js b/gui/pages/Content/Agents/AgentCreate.js
index 969ce268c..a55d69144 100644
--- a/gui/pages/Content/Agents/AgentCreate.js
+++ b/gui/pages/Content/Agents/AgentCreate.js
@@ -9,8 +9,7 @@ import {
getOrganisationConfig,
getLlmModels,
updateExecution,
- uploadFile,
- getAgentDetails, editAgent
+ uploadFile
} from "@/pages/api/DashboardService";
import {
formatBytes,
@@ -35,10 +34,7 @@ export default function AgentCreate({
template,
internalId,
sendKnowledgeData,
- env,
- edit,
- editAgentId,
- agents
+ env
}) {
const [advancedOptions, setAdvancedOptions] = useState(false);
const [agentName, setAgentName] = useState("");
@@ -113,8 +109,6 @@ export default function AgentCreate({
const [createModal, setCreateModal] = useState(false);
const [scheduleData, setScheduleData] = useState(null);
- const [editModal, setEditModal] = useState(false)
-
useEffect(() => {
getOrganisationConfig(organisationId, "model_api_key")
@@ -161,18 +155,25 @@ export default function AgentCreate({
.catch((error) => {
console.error('Error fetching models:', error);
});
- if (edit) {
- editingAgent();
- }
if (template !== null) {
- fillDetails(template)
+ setLocalStorageValue("agent_name_" + String(internalId), template.name, setAgentName);
+ setLocalStorageValue("agent_description_" + String(internalId), template.description, setAgentDescription);
+ setLocalStorageValue("advanced_options_" + String(internalId), true, setAdvancedOptions);
setLocalStorageValue("agent_template_id_" + String(internalId), template.id, setAgentTemplateId);
fetchAgentTemplateConfigLocal(template.id)
.then((response) => {
const data = response.data || [];
- fillAdvancedDetails(data)
+ setLocalStorageArray("agent_goals_" + String(internalId), data.goal, setGoals);
+ setLocalStorageValue("agent_type_" + String(internalId), data.agent_type, setAgentType);
+ setLocalStorageArray("agent_constraints_" + String(internalId), data.constraints, setConstraints);
+ setLocalStorageValue("agent_iterations_" + String(internalId), data.max_iterations, setIterations);
+ setLocalStorageValue("agent_step_time_" + String(internalId), data.iteration_interval, setStepTime);
+ setLocalStorageValue("agent_permission_" + String(internalId), data.permission_type, setPermission);
+ setLocalStorageArray("agent_instructions_" + String(internalId), data.instruction, setInstructions);
+ setLocalStorageValue("agent_database_" + String(internalId), data.LTM_DB, setDatabase);
+ setLocalStorageValue("agent_model_" + String(internalId), data.model, setModel);
setLocalStorageArray("tool_names_" + String(internalId), data.tools, setToolNames);
setLocalStorageValue("is_agent_template_" + String(internalId), true, setShowButton);
setShowButton(true);
@@ -235,44 +236,6 @@ export default function AgentCreate({
setSearchValue('');
};
- const editingAgent = () => {
- const isLoaded = localStorage.getItem('is_editing_agent_' + String(internalId));
- const agent = agents.find(agent => agent.id === editAgentId);
- if (!isLoaded) {
- fillDetails(agent)
- }
- getAgentDetails(editAgentId, -1)
- .then((response) => {
- const data = response.data || []
- if (!isLoaded) {
- fillAdvancedDetails(data)
- setLocalStorageArray("tool_names_" + String(internalId), data.tools.map(tool => tool.name), setToolNames);
- }
- })
- .catch((error) => {
- console.error('Error fetching agent details:', error);
- });
- localStorage.setItem('is_editing_agent_' + String(internalId), true);
- };
-
- const fillDetails = (agent) => {
- setLocalStorageValue("agent_name_" + String(internalId), agent.name, setAgentName);
- setLocalStorageValue("agent_description_" + String(internalId), agent.description, setAgentDescription);
- setLocalStorageValue("advanced_options_" + String(internalId), true, setAdvancedOptions);
- }
- const fillAdvancedDetails = (data) => {
- setLocalStorageArray("agent_goals_" + String(internalId), data.goal, setGoals);
- setLocalStorageValue("agent_type_" + String(internalId), data.agent_type, setAgentType);
- setLocalStorageArray("agent_constraints_" + String(internalId), data.constraints, setConstraints);
- setLocalStorageValue("agent_iterations_" + String(internalId), data.max_iterations, setIterations);
- setLocalStorageValue("agent_step_time_" + String(internalId), data.iteration_interval, setStepTime);
- setLocalStorageValue("agent_permission_" + String(internalId), data.permission_type, setPermission);
- setLocalStorageArray("agent_instructions_" + String(internalId), data.instruction, setInstructions);
- setLocalStorageValue("agent_database_" + String(internalId), data.LTM_DB, setDatabase);
- setLocalStorageValue("agent_model_" + String(internalId), data.model, setModel);
- }
-
-
const addToolkit = (toolkit) => {
const updatedToolIds = [...selectedTools];
const updatedToolNames = [...toolNames];
@@ -511,72 +474,39 @@ export default function AgentCreate({
"schedule": scheduleData,
}
- if(edit){
- agentData.agent_id = editAgentId;
- const name = agentData.name
- agentData.name = `New Run ${new Date()}`
- editAgent(agentData)
- .then((response) => {
- if(response){
- fetchAgents();
- uploadResources(editAgentId, name)
- }
- })
- }
- else
- {
- createAgent(createModal ? scheduleAgentData : agentData, createModal)
- .then((response) => {
- const agentId = response.data.id;
- const name = response.data.name;
- const executionId = response.data.execution_id;
- fetchAgents();
- uploadResources(agentId, name, executionId)
- })
- .catch((error) => {
- console.error('Error creating agent:', error);
- setCreateClickable(true);
- });
- }
- };
+ createAgent(createModal ? scheduleAgentData : agentData, createModal)
+ .then((response) => {
+ const agentId = response.data.id;
+ const name = response.data.name;
+ const executionId = response.data.execution_id;
+ fetchAgents();
+
+ if (addResources && input.length > 0) {
+ const uploadPromises = input.map(fileData => {
+ return uploadResource(agentId, fileData)
+ .catch(error => {
+ console.error('Error uploading resource:', error);
+ return Promise.reject(error);
+ });
+ });
- const uploadResources = (agentId, name, executionId) => {
- if (addResources && input.length > 0) {
- const uploadPromises = input.map(fileData => {
- return uploadResource(agentId, fileData)
+ Promise.all(uploadPromises)
+ .then(() => {
+ runExecution(agentId, name, executionId, createModal);
+ })
.catch(error => {
- console.error('Error uploading resource:', error);
- return Promise.reject(error);
+ console.error('Error uploading files:', error);
+ setCreateClickable(true);
});
+ } else {
+ runExecution(agentId, name, executionId, createModal);
+ }
+ })
+ .catch((error) => {
+ console.error('Error creating agent:', error);
+ setCreateClickable(true);
});
-
- Promise.all(uploadPromises)
- .then(() => {
- runDecision(agentId, name, executionId)
- })
- .catch(error => {
- console.error('Error uploading files:', error);
- setCreateClickable(true);
- });
- } else {
- runDecision(agentId, name, executionId)
- }
- }
-
- const runDecision = (agentId, name, executionId) => {
- if(edit){
- setEditModal(false)
- sendAgentData({
- id: editAgentId,
- name: name,
- contentType: "Agents",
- });
- removeTab(editAgentId, name, "Agents", internalId)
- }
- else {
- runExecution(agentId, name, executionId, createModal);
- }
- }
+ };
const finaliseAgentCreation = (agentId, name, executionId) => {
toast.success('Agent created successfully', {autoClose: 1800});
@@ -845,20 +775,20 @@ export default function AgentCreate({
- {!edit ?
Create new agent
:
Edit agent
}
+
Create new agent
-
+
-
- {goals?.map((goal, index) => (
(
- {constraints?.map((constraint, index) => (
*/}
- {/*
*/}
- {/* */}
- {/* */}
- {/*
*/}
+
+
+
+
{/*
*/}
{/*
*/}
{/*
setLocalStorageValue("has_LTM_" + String(internalId), !longTermMemory, setLongTermMemory)} />*/}
@@ -1278,7 +1208,7 @@ export default function AgentCreate({
Update Template
)}
- {!edit ?
+
{createDropdown && (
{
setCreateModal(true);
setCreateDropdown(false);
@@ -1295,30 +1225,13 @@ export default function AgentCreate({
alt="expand-icon"/>
-
:
-
}
+
{createModal && (
)}
- {editModal && (
setEditModal(!editModal)}>
-
-
Update agent
-
-
-
-
-
-
-
)}
-
diff --git a/gui/pages/Content/Agents/AgentWorkspace.js b/gui/pages/Content/Agents/AgentWorkspace.js
index 1287bbbcc..c59d8fa76 100644
--- a/gui/pages/Content/Agents/AgentWorkspace.js
+++ b/gui/pages/Content/Agents/AgentWorkspace.js
@@ -9,7 +9,7 @@ import RunHistory from "./RunHistory";
import ActionConsole from "./ActionConsole";
import Details from "./Details";
import ResourceManager from "./ResourceManager";
-import {createInternalId, preventDefault} from "@/utils/utils";
+import {preventDefault} from "@/utils/utils";
import {
getAgentDetails,
getAgentExecutions,
@@ -25,7 +25,7 @@ import {EventBus} from "@/utils/eventBus";
import 'moment-timezone';
import AgentSchedule from "@/pages/Content/Agents/AgentSchedule";
-export default function AgentWorkspace({env, agentId, agentName, selectedView, agents, internalId, sendAgentData}) {
+export default function AgentWorkspace({env, agentId, agentName, selectedView, agents, internalId}) {
const [leftPanel, setLeftPanel] = useState('activity_feed')
const [rightPanel, setRightPanel] = useState('details')
const [history, setHistory] = useState(true)
@@ -39,7 +39,7 @@ export default function AgentWorkspace({env, agentId, agentName, selectedView, a
const [agentExecutions, setAgentExecutions] = useState(null)
const [dropdown, setDropdown] = useState(false);
const [fetchedData, setFetchedData] = useState(null);
- const [instructions, setInstructions] = useState([null]);
+ const [instructions, setInstructions] = useState(['']);
const [currentInstructions, setCurrentInstructions] = useState(['']);
const [pendingPermission, setPendingPermissions] = useState(0);
@@ -127,8 +127,6 @@ export default function AgentWorkspace({env, agentId, agentName, selectedView, a
toast.error("Run name can't be blank", {autoClose: 1800});
return
}
- setGoals(goals.length< 0 ? agentDetails.goal : goals)
- setInstructions(instructions.length < 0 ? agentDetails.instruction : instructions)
if (goals.length <= 0) {
toast.error("Agent needs to have goals", {autoClose: 1800});
@@ -146,7 +144,7 @@ export default function AgentWorkspace({env, agentId, agentName, selectedView, a
.then((response) => {
setRunModal(false);
fetchExecutions(agentId, response.data);
- fetchAgentDetails(agentId, selectedRun?.id);
+ fetchAgentDetails(agentId);
EventBus.emit('reFetchAgents', {});
toast.success("New run created", {autoClose: 1800});
})
@@ -211,39 +209,25 @@ export default function AgentWorkspace({env, agentId, agentName, selectedView, a
};
useEffect(() => {
- fetchAgentDetails(agentId, selectedRun?.id);
+ fetchAgentDetails(agentId);
fetchExecutions(agentId);
fetchAgentScheduleComponent()
}, [agentId])
useEffect(() => {
- // fetchExecutionDetails(selectedRun?.id);
- fetchAgentDetails(agentId, selectedRun?.id);
+ fetchExecutionDetails(selectedRun?.id);
}, [selectedRun?.id])
useEffect(() => {
if (agentDetails) {
- setRightPanel(agentDetails.permission_type === 'RESTRICTED' ? 'action_console' : 'details');
+ setRightPanel(agentDetails.permission_type.includes('RESTRICTED') ? 'action_console' : 'details');
}
}, [agentDetails])
- function setNewRunDetails() {
- getAgentDetails(agentId, -1)
+ function fetchAgentDetails(agentId) {
+ getAgentDetails(agentId)
.then((response) => {
- setGoals(response.data.goal)
- setInstructions(response.data.instruction)
- setRunModal(true);
- })
- .catch((error) => {
- console.error('Error fetching agent details:', error);
- });
- }
-
- function fetchAgentDetails(agentId, runId) {
- getAgentDetails(agentId, runId ? runId : -1)
- .then((response) => {
- const data = response.data
- setAgentDetails(data);
+ setAgentDetails(response.data);
})
.catch((error) => {
console.error('Error fetching agent details:', error);
@@ -275,21 +259,21 @@ export default function AgentWorkspace({env, agentId, agentName, selectedView, a
});
}
- // function fetchExecutionDetails(executionId) {
- // getExecutionDetails(executionId || -1, agentId)
- // .then((response) => {
- // setGoals(response.data.goal);
- // setCurrentGoals(response.data.goal);
- // setInstructions(response.data.instruction);
- // setCurrentInstructions(response.data.instruction);
- // })
- // .catch((error) => {
- // console.error('Error fetching agent execution details:', error);
- // });
- // }
+ function fetchExecutionDetails(executionId) {
+ getExecutionDetails(executionId || -1, agentId)
+ .then((response) => {
+ setGoals(response.data.goal);
+ setCurrentGoals(response.data.goal);
+ setInstructions(response.data.instruction);
+ setCurrentInstructions(response.data.instruction);
+ })
+ .catch((error) => {
+ console.error('Error fetching agent execution details:', error);
+ });
+ }
function saveAgentTemplate() {
- saveAgentAsTemplate(agentId, selectedRun?.id)
+ saveAgentAsTemplate(agentId)
.then((response) => {
toast.success("Agent saved as template successfully", {autoClose: 1800});
})
@@ -363,7 +347,7 @@ export default function AgentWorkspace({env, agentId, agentName, selectedView, a
-
@@ -395,12 +379,6 @@ export default function AgentWorkspace({env, agentId, agentName, selectedView, a
setCreateModal(true)
}}>Schedule Run}
)}
-
sendAgentData({
- id: agentId,
- name: "Edit Agent",
- contentType: "Edit_Agent",
- internalId: createInternalId()
- })}>Edit Agent
{
setDropdown(false);
setDeleteModal(true)
@@ -448,7 +426,7 @@ export default function AgentWorkspace({env, agentId, agentName, selectedView, a
- {agentDetails && agentDetails.permission_type === 'RESTRICTED' &&
+ {agentDetails && agentDetails.permission_type.includes('RESTRICTED') &&
setRightPanel('action_console')} className={styles.tab_button}
style={rightPanel === 'action_console' ? {background: '#454254'} : {background: 'transparent'}}>
)}
- {rightPanel === 'details' && agentDetails && agentDetails !== null &&
-
}
diff --git a/gui/pages/Content/Agents/Details.js b/gui/pages/Content/Agents/Details.js
index 5f9c682df..bf0123919 100644
--- a/gui/pages/Content/Agents/Details.js
+++ b/gui/pages/Content/Agents/Details.js
@@ -4,13 +4,13 @@ import Image from "next/image";
import {formatNumber} from "@/utils/utils";
import {EventBus} from "@/utils/eventBus";
-export default function Details({agentDetails1, runCount, agentScheduleDetails, agent}) {
+export default function Details({agentDetails, runCount, goals, instructions, agentScheduleDetails, agent}) {
const [showGoals, setShowGoals] = useState(false);
const [showConstraints, setShowConstraints] = useState(false);
const [showInstructions, setShowInstructions] = useState(false);
- const [filteredInstructions, setFilteredInstructions] = useState([]);
+ const [filteredInstructions, setFilteredInstructions] = useState(false);
const [scheduleText, setScheduleText] = useState('Agent is not Scheduled');
- const [agentDetails, setAgentDetails] = useState(null)
+
const info_text = {
marginLeft: '7px',
};
@@ -28,13 +28,8 @@ export default function Details({agentDetails1, runCount, agentScheduleDetails,
}
useEffect(() => {
- if (Array.isArray(agentDetails?.instruction)) {
- setFilteredInstructions(agentDetails.instruction.filter(instruction => instruction.trim() !== ''));
- }
- }, [agentDetails]);
- useEffect(() => {
- setAgentDetails(agentDetails1)
- }, [agentDetails1]);
+ setFilteredInstructions(instructions?.filter(instruction => instruction.trim() !== ''));
+ }, [instructions]);
useEffect(() => {
if (agent?.is_scheduled) {
@@ -101,13 +96,13 @@ export default function Details({agentDetails1, runCount, agentScheduleDetails,
-
{agentDetails?.goal?.length || 0} Goals
+
{goals ? goals.length : 0} Goals
- {agentDetails?.goal && agentDetails?.goal?.length > 0 &&
+ {goals && goals.length > 0 &&
- {agentDetails?.goal?.map((goal, index) => (
+ {goals.map((goal, index) => (
{index + 1}. {goal || ''}
- {index !== agentDetails?.goal?.length - 1 &&
}
+ {index !== goals.length - 1 &&
}
))}
setShowGoals(!showGoals)}>
@@ -139,14 +134,14 @@ export default function Details({agentDetails1, runCount, agentScheduleDetails,
Tools assigned
- {agentDetails?.tools?.map((tool, index) =>
+ {agentDetails.tools.map((tool, index) =>
(
openToolkitTab(tool.id)} key={index} className="tool_container"
style={{marginTop: '0', marginBottom: '5px', cursor: 'pointer'}}>
{tool.name || ''}
))}
}
}
- {agentDetails &&
{agentDetails.constraints && agentDetails.constraints?.length > 0 &&
+ {agentDetails &&
{agentDetails.constraints && agentDetails.constraints.length > 0 &&
@@ -154,7 +149,7 @@ export default function Details({agentDetails1, runCount, agentScheduleDetails,
- {agentDetails?.constraints?.map((constraint, index) => (
+ {agentDetails.constraints.map((constraint, index) => (
{index + 1}. {constraint || ''}
{index !== agentDetails.constraints.length - 1 &&
}
))}
@@ -185,7 +180,7 @@ export default function Details({agentDetails1, runCount, agentScheduleDetails,
*/}
-
{agentDetails?.permission_type?.replace(/\s*\([^)]*\)/g, '') || ''}
+
{agentDetails?.permission_type.replace(/\s*\([^)]*\)/g, '') || ''}
{agentDetails?.max_iterations &&
diff --git a/gui/pages/Dashboard/Content.js b/gui/pages/Dashboard/Content.js
index 4e86bbeab..6c94c517e 100644
--- a/gui/pages/Dashboard/Content.js
+++ b/gui/pages/Dashboard/Content.js
@@ -4,7 +4,6 @@ import Knowledge from '../Content/Knowledge/Knowledge';
import AddKnowledge from '../Content/Knowledge/AddKnowledge';
import KnowledgeDetails from '../Content/Knowledge/KnowledgeDetails';
import AgentWorkspace from '../Content/Agents/AgentWorkspace';
-import AgentCreate from '../Content/Agents/AgentCreate';
import ToolkitWorkspace from '../Content/./Toolkits/ToolkitWorkspace';
import Toolkits from '../Content/./Toolkits/Toolkits';
import Settings from "./Settings/Settings";
@@ -40,7 +39,7 @@ export default function Content({env, selectedView, selectedProjectId, organisat
const [toolkitDetails, setToolkitDetails] = useState({});
const [starModal, setStarModal] = useState(false);
const router = useRouter();
- const multipleTabContentTypes = ['Create_Agent', 'Add_Toolkit', 'Add_Knowledge', 'Add_Database','Edit_Agent'];
+ const multipleTabContentTypes = ['Create_Agent', 'Add_Toolkit', 'Add_Knowledge', 'Add_Database'];
const [isApmOpened, setIsApmOpened] = useState(false);
const [prevView, setPrevView] = useState(null);
@@ -376,7 +375,7 @@ export default function Content({env, selectedView, selectedProjectId, organisat
selectTab(tab, index)
}}>
- {(tab.contentType === 'Agents' || tab.contentType === 'Create_Agent' || tab.contentType === 'Edit_Agent') &&
+ {(tab.contentType === 'Agents' || tab.contentType === 'Create_Agent') &&
}
{(tab.contentType === 'Toolkits' || tab.contentType === 'Add_Toolkit') &&
@@ -418,7 +417,7 @@ export default function Content({env, selectedView, selectedProjectId, organisat
{tab.contentType === 'Agents' &&
}
+ agents={agents} fetchAgents={getAgentList}/>}
{tab.contentType === 'Toolkits' &&
}
@@ -444,11 +443,6 @@ export default function Content({env, selectedView, selectedProjectId, organisat
sendAgentData={addTab} selectedProjectId={selectedProjectId}
fetchAgents={getAgentList} toolkits={toolkits} env={env} />}
{tab.contentType === 'APM' && }
- {tab.contentType === 'Edit_Agent' &&
- }
}
))}
diff --git a/gui/pages/_app.css b/gui/pages/_app.css
index 8e39ea591..b197dd1c4 100644
--- a/gui/pages/_app.css
+++ b/gui/pages/_app.css
@@ -1002,7 +1002,6 @@ p {
.w_20{width: 20%}
.w_22{width: 22%}
.w_56{width: 56%}
-.w_35{width: 35%}
.w_100{width: 100%}
.w_inherit{width: inherit}
.w_fit_content{width:fit-content}
@@ -1013,7 +1012,6 @@ p {
.h_100{height: 100%}
.h_auto{height: auto}
.h_75vh{height: 75vh}
-.h_32p{height: 32px}
.mxh_78vh{max-height: 78vh}
@@ -1067,7 +1065,6 @@ p {
.padding_8_6{padding: 8px 6px;}
.padding_2_8{padding: 2px 8px;}
.padding_0_8{padding: 0px 8px;}
-.padding_0_15{padding: 0px 15px;}
.flex_wrap{flex-wrap: wrap;}
diff --git a/gui/pages/api/DashboardService.js b/gui/pages/api/DashboardService.js
index 85a063636..18e429fa3 100644
--- a/gui/pages/api/DashboardService.js
+++ b/gui/pages/api/DashboardService.js
@@ -28,8 +28,8 @@ export const getTools = () => {
return api.get(`/tools/list`);
};
-export const getAgentDetails = (agentId, agentExecutionId) => {
- return api.get(`/agent_executions_configs/details/agent_id/${agentId}/agent_execution_id/${agentExecutionId}`);
+export const getAgentDetails = (agentId) => {
+ return api.get(`/agents/get/details/${agentId}`);
};
export const getAgentExecutions = (agentId) => {
@@ -48,10 +48,6 @@ export const createAgent = (agentData, scheduledCreate) => {
return api.post(scheduledCreate ? `/agents/schedule` : `/agents/create`, agentData);
};
-export const editAgent = (agentData) => {
- return api.post( `/agentexecutions/add_run`, agentData);
-};
-
export const addTool = (toolData) => {
return api.post(`/toolkits/get/local/install`, toolData);
};
@@ -124,8 +120,8 @@ export const fetchAgentTemplateListLocal = () => {
return api.get('/agent_templates/list?template_source=local');
};
-export const saveAgentAsTemplate = (agentId, executionId) => {
- return api.post(`/agent_templates/save_agent_as_template/agent_id/${agentId}/agent_execution_id/${executionId}`);
+export const saveAgentAsTemplate = (agentId) => {
+ return api.post(`/agent_templates/save_agent_as_template/${agentId}`);
};
export const fetchAgentTemplateConfig = (templateId) => {
diff --git a/gui/utils/utils.js b/gui/utils/utils.js
index 899520965..0fad9209a 100644
--- a/gui/utils/utils.js
+++ b/gui/utils/utils.js
@@ -285,7 +285,6 @@ const removeAgentInternalId = (internalId) => {
localStorage.removeItem("agent_template_id_" + String(internalId));
localStorage.removeItem("agent_knowledge_" + String(internalId));
localStorage.removeItem("agent_knowledge_id_" + String(internalId));
- localStorage.removeItem("is_editing_agent_" + String(internalId));
}
};