diff --git a/.github/ISSUE_TEMPLATE/1.BUG_REPORT.yml b/.github/ISSUE_TEMPLATE/1.BUG_REPORT.yml index 2604bff96..dfa1641cd 100644 --- a/.github/ISSUE_TEMPLATE/1.BUG_REPORT.yml +++ b/.github/ISSUE_TEMPLATE/1.BUG_REPORT.yml @@ -15,7 +15,6 @@ body: [#general]: https://discord.com/channels/1107593006032355359/1107642413993959505 [#support]: https://discord.com/channels/1107593006032355359/1107645922797703198 [existing issues]: https://github.com/TransformerOptimus/SuperAGI/issues - - type: checkboxes attributes: label: ⚠️ Check for existing issues before proceeding. ⚠️ diff --git a/config_template.yaml b/config_template.yaml index f6ccdbc26..5df3421b7 100644 --- a/config_template.yaml +++ b/config_template.yaml @@ -11,6 +11,7 @@ OPENAI_API_BASE: https://api.openai.com/v1 # "gpt-3.5-turbo-0301": 4032, "gpt-4-0314": 8092, "gpt-3.5-turbo": 4032, "gpt-4": 8092, "gpt-4-32k": 32768, "gpt-4-32k-0314": 32768, "llama":2048, "mpt-7b-storywriter":45000 MODEL_NAME: "gpt-3.5-turbo-0301" +RESOURCES_SUMMARY_MODEL_NAME: "gpt-3.5-turbo" MAX_TOOL_TOKEN_LIMIT: 800 MAX_MODEL_TOKEN_LIMIT: 4032 # set to 2048 for llama @@ -91,4 +92,20 @@ SLACK_BOT_TOKEN: YOUR_SLACK_BOT_TOKEN # For running stable diffusion STABILITY_API_KEY: YOUR_STABILITY_API_KEY #Engine IDs that can be used: 'stable-diffusion-v1', 'stable-diffusion-v1-5','stable-diffusion-512-v2-0', 'stable-diffusion-768-v2-0','stable-diffusion-512-v2-1','stable-diffusion-768-v2-1','stable-diffusion-xl-beta-v2-2-2' -ENGINE_ID: "stable-diffusion-xl-beta-v2-2-2" \ No newline at end of file +ENGINE_ID: "stable-diffusion-xl-beta-v2-2-2" + +# To config a vector store for resources manager +# RESOURCE_VECTOR_STORE can be REDIS, PINECONE, CHROMA, QDRANT +RESOURCE_VECTOR_STORE: YOUR_RESOURCE_VECTOR_STORE +RESOURCE_VECTOR_STORE_INDEX_NAME: YOUR_RESOURCE_VECTOR_STORE_INDEX_NAME + +# To use a custom redis +REDIS_VECTOR_STORE_URL: YOUR_REDIS_VECTOR_STORE_URL + +# To use qdrant for vector store in resources manager +QDRANT_PORT: YOUR_QDRANT_PORT +QDRANT_HOST_NAME: YOUR_QDRANT_HOST_NAME + +# To use chroma for vector store in resources manager +CHROMA_HOST_NAME: YOUR_CHROMA_HOST_NAME +CHROMA_PORT: YOUR_CHROMA_PORT \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index afaff531c..6dabb981d 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -32,9 +32,15 @@ services: # - /app/node_modules/ # - /app/.next/ super__redis: - image: "docker.io/library/redis:latest" + image: "redis/redis-stack-server:latest" networks: - super_network +# uncomment to expose redis port to host +# ports: +# - "6379:6379" + volumes: + - redis_data:/data + super__postgres: image: "docker.io/library/postgres:latest" environment: @@ -45,6 +51,9 @@ services: - superagi_postgres_data:/var/lib/postgresql/data/ networks: - super_network +# uncomment to expose postgres port to host +# ports: +# - "5432:5432" proxy: image: nginx:stable-alpine @@ -58,9 +67,9 @@ services: volumes: - ./nginx/default.conf:/etc/nginx/conf.d/default.conf - networks: super_network: driver: bridge volumes: superagi_postgres_data: + redis_data: diff --git a/gui/package-lock.json b/gui/package-lock.json index 59050322f..f6d699511 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -13,6 +13,7 @@ "date-fns": "^2.30.0", "eslint": "8.40.0", "eslint-config-next": "13.4.2", + "jszip": "^3.10.1", "mitt": "^3.0.0", "next": "13.4.2", "react": "18.2.0", @@ -845,6 +846,11 @@ "version": "0.0.1", "license": "MIT" }, + "node_modules/core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" + }, "node_modules/cross-spawn": { "version": "7.0.3", "license": "MIT", @@ -1966,6 +1972,11 @@ "node": ">= 4" } }, + "node_modules/immediate": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz", + "integrity": "sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==" + }, "node_modules/import-fresh": { "version": "3.3.0", "license": "MIT", @@ -2416,6 +2427,17 @@ "node": ">=4.0" } }, + "node_modules/jszip": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.10.1.tgz", + "integrity": "sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g==", + "dependencies": { + "lie": "~3.3.0", + "pako": "~1.0.2", + "readable-stream": "~2.3.6", + "setimmediate": "^1.0.5" + } + }, "node_modules/kleur": { "version": "4.1.5", "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz", @@ -2446,6 +2468,14 @@ "node": ">= 0.8.0" } }, + "node_modules/lie": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/lie/-/lie-3.3.0.tgz", + "integrity": "sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==", + "dependencies": { + "immediate": "~3.0.5" + } + }, "node_modules/locate-path": { "version": "6.0.0", "license": "MIT", @@ -3330,6 +3360,11 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/pako": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", + "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==" + }, "node_modules/parent-module": { "version": "1.0.1", "license": "MIT", @@ -3415,6 +3450,11 @@ "node": ">= 0.8.0" } }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + }, "node_modules/prop-types": { "version": "15.8.1", "license": "MIT", @@ -3533,6 +3573,25 @@ "react-dom": ">=16" } }, + "node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/readable-stream/node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" + }, "node_modules/regenerator-runtime": { "version": "0.13.11", "license": "MIT" @@ -3744,6 +3803,11 @@ "node": ">=6" } }, + "node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, "node_modules/safe-regex-test": { "version": "1.0.0", "license": "MIT", @@ -3776,6 +3840,11 @@ "node": ">=10" } }, + "node_modules/setimmediate": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", + "integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==" + }, "node_modules/shebang-command": { "version": "2.0.0", "license": "MIT", @@ -3848,6 +3917,14 @@ "node": ">=10.0.0" } }, + "node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, "node_modules/string.prototype.matchall": { "version": "4.0.8", "license": "MIT", @@ -4245,6 +4322,11 @@ "punycode": "^2.1.0" } }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" + }, "node_modules/uvu": { "version": "0.5.6", "resolved": "https://registry.npmjs.org/uvu/-/uvu-0.5.6.tgz", diff --git a/gui/package.json b/gui/package.json index e45e985e1..71296d5ea 100644 --- a/gui/package.json +++ b/gui/package.json @@ -15,6 +15,7 @@ "date-fns": "^2.30.0", "eslint": "8.40.0", "eslint-config-next": "13.4.2", + "jszip": "^3.10.1", "mitt": "^3.0.0", "next": "13.4.2", "react": "18.2.0", diff --git a/gui/pages/Content/Agents/ActivityFeed.js b/gui/pages/Content/Agents/ActivityFeed.js index 7418e9358..15dc9cb52 100644 --- a/gui/pages/Content/Agents/ActivityFeed.js +++ b/gui/pages/Content/Agents/ActivityFeed.js @@ -5,7 +5,7 @@ import Image from "next/image"; import {loadingTextEffect, formatTimeDifference} from "@/utils/utils"; import {EventBus} from "@/utils/eventBus"; -export default function ActivityFeed({selectedRunId, selectedView, setFetchedData }) { +export default function ActivityFeed({selectedRunId, selectedView, setFetchedData, runModal }) { const [loadingText, setLoadingText] = useState("Thinking"); const [feeds, setFeeds] = useState([]); const feedContainerRef = useRef(null); @@ -18,7 +18,7 @@ export default function ActivityFeed({selectedRunId, selectedView, setFetchedDat useEffect(() => { const interval = window.setInterval(function(){ - fetchFeeds(); + fetchFeeds(); }, 10000); return () => clearInterval(interval); @@ -60,6 +60,7 @@ export default function ActivityFeed({selectedRunId, selectedView, setFetchedDat setFeeds(data.feeds); setRunStatus(data.status); setFetchedData(data.permissions); + EventBus.emit('resetRunStatus', {executionId: selectedRunId, status: data.status}); }) .catch((error) => { console.error('Error fetching execution feeds:', error); diff --git a/gui/pages/Content/Agents/AgentCreate.js b/gui/pages/Content/Agents/AgentCreate.js index 86fdee027..7a52c4b9c 100644 --- a/gui/pages/Content/Agents/AgentCreate.js +++ b/gui/pages/Content/Agents/AgentCreate.js @@ -3,16 +3,26 @@ import Image from "next/image"; import {ToastContainer, toast} from 'react-toastify'; import 'react-toastify/dist/ReactToastify.css'; import styles from './Agents.module.css'; -import {createAgent, fetchAgentTemplateConfigLocal, getOrganisationConfig, uploadFile} from "@/pages/api/DashboardService"; -import {formatBytes, openNewTab, removeTab} from "@/utils/utils"; +import { + createAgent, + fetchAgentTemplateConfigLocal, + getOrganisationConfig, + updateExecution, + uploadFile +} from "@/pages/api/DashboardService"; +import { + formatBytes, + openNewTab, + removeTab, + setLocalStorageValue, + setLocalStorageArray, +} from "@/utils/utils"; import {EventBus} from "@/utils/eventBus"; -export default function AgentCreate({sendAgentData, selectedProjectId, fetchAgents, toolkits, organisationId, template}) { +export default function AgentCreate({sendAgentData, selectedProjectId, fetchAgents, toolkits, organisationId, template, internalId}) { const [advancedOptions, setAdvancedOptions] = useState(false); const [agentName, setAgentName] = useState(""); const [agentDescription, setAgentDescription] = useState(""); - const [selfEvaluation, setSelfEvaluation] = useState(''); - const [basePrompt, setBasePrompt] = useState(''); const [longTermMemory, setLongTermMemory] = useState(true); const [addResources, setAddResources] = useState(true); const [input, setInput] = useState([]); @@ -74,7 +84,7 @@ export default function AgentCreate({sendAgentData, selectedProjectId, fetchAgen const toolkitRef = useRef(null); const [toolkitDropdown, setToolkitDropdown] = useState(false); - const excludedToolkits = ["Thinking Toolkit", "Human Input Toolkit"]; + const excludedToolkits = ["Thinking Toolkit", "Human Input Toolkit","Resource Toolkit"]; const [hasAPIkey, setHasAPIkey] = useState(false); useEffect(() => { @@ -95,12 +105,12 @@ export default function AgentCreate({sendAgentData, selectedProjectId, fetchAgen .filter(tool => toolNames.includes(tool.name)) .map(tool => tool.id); - setSelectedTools(selectedToolIds); + setLocalStorageArray("tool_ids_" + String(internalId), selectedToolIds, setSelectedTools); } }; const handleIterationChange = (event) => { - setIterations(parseInt(event.target.value)); + setLocalStorageValue("agent_iterations_" + String(internalId), parseInt(event.target.value), setIterations); }; useEffect(() => { @@ -109,33 +119,24 @@ export default function AgentCreate({sendAgentData, selectedProjectId, fetchAgen useEffect(() => { if(template !== null) { - setAgentName(template.name) - setAgentDescription(template.description) - setAdvancedOptions(true) + setLocalStorageValue("agent_name_" + String(internalId), template.name, setAgentName); + setLocalStorageValue("agent_description_" + String(internalId), template.description, setAgentDescription); + setLocalStorageValue("advanced_options_" + String(internalId), true, setAdvancedOptions); fetchAgentTemplateConfigLocal(template.id) .then((response) => { const data = response.data || []; - setGoals(data.goal) - setAgentType(data.agent_type) - setConstraints(data.constraints) - setIterations(data.max_iterations) - setRollingWindow(data.memory_window) - setPermission(data.permission_type) - setStepTime(data.iteration_interval) - setInstructions(data.instruction) - setDatabase(data.LTM_DB) - setModel(data.model) - data.tools.forEach((item) => { - toolkitList.forEach((toolkit) => { - toolkit.tools.forEach((tool) => { - if (tool.name === item) { - setSelectedTools((prevArray) => [...prevArray, tool.id]); - } - }); - }); - }); - setToolNames(data.tools) + 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_rolling_window_" + String(internalId), data.memory_window, setRollingWindow); + 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); }) .catch((error) => { console.error('Error fetching template details:', error); @@ -182,130 +183,129 @@ export default function AgentCreate({sendAgentData, selectedProjectId, fetchAgen const addTool = (tool) => { if (!selectedTools.includes(tool.id) && !toolNames.includes(tool.name)) { - setSelectedTools((prevArray) => [...prevArray, tool.id]); - setToolNames((prevArray) => [...prevArray, tool.name]); + const updatedToolIds = [...selectedTools, tool.id]; + setLocalStorageArray("tool_ids_" + String(internalId), updatedToolIds, setSelectedTools); + + const updatedToolNames = [...toolNames, tool.name]; + setLocalStorageArray("tool_names_" + String(internalId), updatedToolNames, setToolNames); } setSearchValue(''); }; const addToolkit = (toolkit) => { + const updatedToolIds = [...selectedTools]; + const updatedToolNames = [...toolNames]; + toolkit.tools.map((tool) => { if (!selectedTools.includes(tool.id) && !toolNames.includes(tool.name)) { - setSelectedTools((prevArray) => [...prevArray, tool.id]); - setToolNames((prevArray) => [...prevArray, tool.name]); + updatedToolIds.push(tool.id); + updatedToolNames.push(tool.name); } }); + + setLocalStorageArray("tool_ids_" + String(internalId), updatedToolIds, setSelectedTools); + setLocalStorageArray("tool_names_" + String(internalId), updatedToolNames, setToolNames); setSearchValue(''); } const removeTool = (indexToDelete) => { - setSelectedTools((prevArray) => { - const newArray = [...prevArray]; - newArray.splice(indexToDelete, 1); - return newArray; - }); + const updatedToolIds = [...selectedTools]; + updatedToolIds.splice(indexToDelete, 1); + setLocalStorageArray("tool_ids_" + String(internalId), updatedToolIds, setSelectedTools); - setToolNames((prevArray) => { - const newArray = [...prevArray]; - newArray.splice(indexToDelete, 1); - return newArray; - }); + const updatedToolNames = [...toolNames]; + updatedToolNames.splice(indexToDelete, 1); + setLocalStorageArray("tool_names_" + String(internalId), updatedToolNames, setToolNames); }; const handlePermissionSelect = (index) => { - setPermission(permissions[index]); + setLocalStorageValue("agent_permission_" + String(internalId), permissions[index], setPermission); setPermissionDropdown(false); }; const handleDatabaseSelect = (index) => { - setDatabase(databases[index]); + setLocalStorageValue("agent_database_" + String(internalId), databases[index], setDatabase); setDatabaseDropdown(false); }; const handleWindowSelect = (index) => { - setRollingWindow(rollingWindows[index]); + setLocalStorageValue("agent_rolling_window_" + String(internalId), rollingWindows[index], setRollingWindow); setRollingDropdown(false); }; const handleStepChange = (event) => { - setStepTime(event.target.value) + setLocalStorageValue("agent_step_time_" + String(internalId), event.target.value, setStepTime); }; const handleExitSelect = (index) => { - setExitCriterion(exitCriteria[index]); + setLocalStorageValue("agent_exit_criterion_" + String(internalId), exitCriteria[index], setExitCriterion); setExitDropdown(false); }; const handleAgentSelect = (index) => { - setAgentType(agentTypes[index]); + setLocalStorageValue("agent_type_" + String(internalId), agentTypes[index], setAgentType); setAgentDropdown(false); }; const handleModelSelect = (index) => { - setModel(models[index]); + setLocalStorageValue("agent_model_" + String(internalId), models[index], setModel); setModelDropdown(false); }; const handleGoalChange = (index, newValue) => { const updatedGoals = [...goals]; updatedGoals[index] = newValue; - setGoals(updatedGoals); + setLocalStorageArray("agent_goals_" + String(internalId), updatedGoals, setGoals); }; + const handleInstructionChange = (index, newValue) => { const updatedInstructions = [...instructions]; updatedInstructions[index] = newValue; - setInstructions(updatedInstructions); + setLocalStorageArray("agent_instructions_" + String(internalId), updatedInstructions, setInstructions); }; const handleConstraintChange = (index, newValue) => { const updatedConstraints = [...constraints]; updatedConstraints[index] = newValue; - setConstraints(updatedConstraints); + setLocalStorageArray("agent_constraints_" + String(internalId), updatedConstraints, setConstraints); }; const handleGoalDelete = (index) => { const updatedGoals = [...goals]; updatedGoals.splice(index, 1); - setGoals(updatedGoals); + setLocalStorageArray("agent_goals_" + String(internalId), updatedGoals, setGoals); }; const handleInstructionDelete = (index) => { const updatedInstructions = [...instructions]; updatedInstructions.splice(index, 1); - setInstructions(updatedInstructions); + setLocalStorageArray("agent_instructions_" + String(internalId), updatedInstructions, setInstructions); }; const handleConstraintDelete = (index) => { const updatedConstraints = [...constraints]; updatedConstraints.splice(index, 1); - setConstraints(updatedConstraints); + setLocalStorageArray("agent_constraints_" + String(internalId), updatedConstraints, setConstraints); }; const addGoal = () => { - setGoals((prevArray) => [...prevArray, 'new goal']); + setLocalStorageArray("agent_goals_" + String(internalId), [...goals, 'new goal'], setGoals); }; + const addInstruction = () => { - setInstructions((prevArray) => [...prevArray, 'new instructions']); + setLocalStorageArray("agent_instructions_" + String(internalId), [...instructions, 'new instructions'], setInstructions); }; const addConstraint = () => { - setConstraints((prevArray) => [...prevArray, 'new constraint']); + setLocalStorageArray("agent_constraints_" + String(internalId), [...constraints, 'new constraint'], setConstraints); }; const handleNameChange = (event) => { - setAgentName(event.target.value); + setLocalStorageValue("agent_name_" + String(internalId), event.target.value, setAgentName); }; const handleDescriptionChange = (event) => { - setAgentDescription(event.target.value); - }; - - const handleSelfEvaluationChange = (event) => { - setSelfEvaluation(event.target.value); - }; - - const handleBasePromptChange = (event) => { - setBasePrompt(event.target.value); + setLocalStorageValue("agent_description_" + String(internalId), event.target.value, setAgentDescription); }; const preventDefault = (e) => { @@ -390,23 +390,31 @@ export default function AgentCreate({sendAgentData, selectedProjectId, fetchAgen createAgent(agentData) .then((response) => { - const agent_id = response.data.id; + const agentId = response.data.id; + const name = response.data.name; + const executionId = response.data.execution_id; fetchAgents(); - removeTab(-1, "new agent", "Create_Agent"); - sendAgentData({ id: agent_id, name: response.data.name, contentType: "Agents", execution_id: response.data.execution_id }); - if(addResources) { - input.forEach((fileData) => { - input.forEach(fileData => { - uploadResource(agent_id, fileData) - .then(response => {}) - .catch(error => { - console.error('Error uploading resource:', error); - }); - }); + + 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); + }); }); + + Promise.all(uploadPromises) + .then(() => { + runExecution(agentId, name, executionId); + }) + .catch(error => { + console.error('Error uploading files:', error); + setCreateClickable(true); + }); + } else { + runExecution(agentId, name, executionId); } - toast.success('Agent created successfully', {autoClose: 1800}); - setCreateClickable(true); }) .catch((error) => { console.error('Error creating agent:', error); @@ -414,6 +422,19 @@ export default function AgentCreate({sendAgentData, selectedProjectId, fetchAgen }); }; + function runExecution(agentId, name, executionId) { + updateExecution(executionId, {"status": 'RUNNING'}) + .then((response) => { + toast.success('Agent created successfully', { autoClose: 1800 }); + sendAgentData({ id: agentId, name: name, contentType: "Agents", execution_id: executionId }); + setCreateClickable(true); + }) + .catch((error) => { + setCreateClickable(true); + console.error('Error updating execution:', error); + }); + } + const toggleToolkit = (e, id) => { e.stopPropagation(); const toolkitToUpdate = toolkitList.find(toolkit => toolkit.id === id); @@ -432,8 +453,8 @@ export default function AgentCreate({sendAgentData, selectedProjectId, fetchAgen const clearTools = (e) => { e.stopPropagation(); - setSelectedTools([]); - setToolNames([]); + setLocalStorageArray("tool_names_" + String(internalId), [], setToolNames); + setLocalStorageArray("tool_ids_" + String(internalId), [], setSelectedTools); }; const handleFileInputChange = (event) => { @@ -466,7 +487,8 @@ export default function AgentCreate({sendAgentData, selectedProjectId, fetchAgen "size": files[0].size, "type": files[0].type, }; - setInput((prevArray) => [...prevArray, fileData]); + const updatedFiles = [...input, fileData]; + setLocalStorageArray('agent_files_' + String(internalId), updatedFiles, setInput); } } @@ -485,7 +507,7 @@ export default function AgentCreate({sendAgentData, selectedProjectId, fetchAgen const removeFile = (index) => { const updatedFiles = input.filter((file) => input.indexOf(file) !== index); - setInput(updatedFiles); + setLocalStorageArray('agent_files_' + String(internalId), updatedFiles, setInput); }; const ResourceItem = ({ file, index }) => { @@ -518,6 +540,103 @@ export default function AgentCreate({sendAgentData, selectedProjectId, fetchAgen ); + useEffect(() => { + const has_resource = localStorage.getItem("has_resource_" + String(internalId)); + if(has_resource) { + setAddResources(JSON.parse(has_resource)); + } + + const has_LTM = localStorage.getItem("has_LTM_" + String(internalId)); + if(has_LTM) { + setLongTermMemory(JSON.parse(has_LTM)); + } + + const advanced_options = localStorage.getItem("advanced_options_" + String(internalId)); + if(advanced_options) { + setAdvancedOptions(JSON.parse(advanced_options)); + } + + const agent_name = localStorage.getItem("agent_name_" + String(internalId)); + if(agent_name) { + setAgentName(agent_name); + } + + const agent_description = localStorage.getItem("agent_description_" + String(internalId)); + if(agent_description) { + setAgentDescription(agent_description); + } + + const agent_goals = localStorage.getItem("agent_goals_" + String(internalId)); + if(agent_goals) { + setGoals(JSON.parse(agent_goals)); + } + + const tool_ids = localStorage.getItem("tool_ids_" + String(internalId)); + if(tool_ids) { + setSelectedTools(JSON.parse(tool_ids)); + } + + const tool_names = localStorage.getItem("tool_names_" + String(internalId)); + if(tool_names) { + setToolNames(JSON.parse(tool_names)); + } + + const agent_instructions = localStorage.getItem("agent_instructions_" + String(internalId)); + if(agent_instructions) { + setInstructions(JSON.parse(agent_instructions)); + } + + const agent_constraints = localStorage.getItem("agent_constraints_" + String(internalId)); + if(agent_constraints) { + setConstraints(JSON.parse(agent_constraints)); + } + + const agent_model = localStorage.getItem("agent_model_" + String(internalId)); + if(agent_model) { + setModel(agent_model); + } + + const agent_type = localStorage.getItem("agent_type_" + String(internalId)); + if(agent_type) { + setAgentType(agent_type); + } + + const agent_rolling_window = localStorage.getItem("agent_rolling_window_" + String(internalId)); + if(agent_rolling_window) { + setRollingWindow(agent_rolling_window); + } + + const agent_database = localStorage.getItem("agent_database_" + String(internalId)); + if(agent_database) { + setDatabase(agent_database); + } + + const agent_permission = localStorage.getItem("agent_permission_" + String(internalId)); + if(agent_permission) { + setPermission(agent_permission); + } + + const exit_criterion = localStorage.getItem("agent_exit_criterion_" + String(internalId)); + if(exit_criterion) { + setExitCriterion(exit_criterion); + } + + const iterations = localStorage.getItem("agent_iterations_" + String(internalId)); + if(iterations) { + setIterations(Number(iterations)); + } + + const step_time = localStorage.getItem("agent_step_time_" + String(internalId)); + if(step_time) { + setStepTime(Number(step_time)); + } + + const agent_files = localStorage.getItem("agent_files_" + String(internalId)); + if(agent_files) { + setInput(JSON.parse(agent_files)); + } + }, [internalId]) + return (<>
@@ -622,7 +741,7 @@ export default function AgentCreate({sendAgentData, selectedProjectId, fetchAgen
-
@@ -643,20 +762,10 @@ export default function AgentCreate({sendAgentData, selectedProjectId, fetchAgen - {/*
*/} - {/*
*/} - {/*

This will defined the agent role definitely and reduces hallucination. This will defined the agent role definitely and reduces hallucination.

*/} - {/*