diff --git a/Dockerfile b/Dockerfile index 250f94a12..420f68cad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,3 +33,5 @@ COPY --from=compile-image /app /app COPY --from=compile-image /root/nltk_data /root/nltk_data ENV PATH="/opt/venv/bin:$PATH" + +EXPOSE 8001 \ No newline at end of file diff --git a/README.MD b/README.MD index b11a7b514..16bb5a6f5 100644 --- a/README.MD +++ b/README.MD @@ -12,9 +12,10 @@

- + - + +

@@ -75,14 +76,15 @@


-## 📽 Demo Video Showcasing SuperCoder (A SuperAGI agent template) +## 📽 Setting Up SuperAGI using Docker Hub -[Demo Video](https://github.com/Akki-jain/test/assets/92881074/bb18407a-b6b2-4a9f-9419-ec73ffacd2f8) +

+ +

-This video demonstrates how SuperCoder can be used to create simple applications like a personal finance calculator.

-
Not sure how to setup? Learn here +
Not sure how to setup? Learn here

@@ -94,31 +96,18 @@ This video demonstrates how SuperCoder can be used to create simple applications - Graphical User Interface - Action Console - Multiple Vector DBs -- Multi-Modal Agents - Agent Trajectory Fine-Tuning -- Performance Telemetry -- Optimized Token Usage +- Performance Monitoring - Agent Memory Storage -- Looping Detection Heuristics -- Concurrent Agents - Resource Manager ## 🛠 Tools -Slack Email Twitter Jira File Manager Google Search Dall-E Github Web Interaction Zapier Instagram Trello Google Analytics Duckduckgo Discord +Twitter Coding Tool Instagram Knowledge Search Email Jira File Manager Google Search Dall-E Github Web Interaction Duckduckgo Google Calendar Google Calendar Serp API Searx Web Scraper Notion Apollo ## 💻 Screenshots -[//]: # (**CLI View**) - -[//]: # (![CLI](https://superagi.co/wp-content/uploads/2023/05/CLI.png)) - -**GUI** -

- - SuperAGI logo - SuperAGI logo @@ -126,7 +115,7 @@ This video demonstrates how SuperCoder can be used to create simple applications ## 🛣 Roadmap -[Click here to checkout the latest roadmap 🔗](https://github.com/users/TransformerOptimus/projects/1) +[Click here to checkout the latest roadmap 🔗](https://github.com/users/TransformerOptimus/projects/5/views/1) @@ -187,14 +176,6 @@ This video demonstrates how SuperCoder can be used to create simple applications ## ⚠️ Under Development! This project is under active development and may still have issues. We appreciate your understanding and patience. If you encounter any problems, please first check the open issues. If your issue is not listed, kindly create a new issue detailing the error or problem you experienced. Thank you for your support! -## 📽 Curated Videos - -|-| -|--| -|[GitHub Codespaces](https://youtu.be/iSPHZ1onQ44)| -|[Windows/MacOS/Linux](https://youtu.be/Unj5NLNTkLY)| -[GUI Walkthrough](https://youtu.be/7FXESG6BOgw)| -[Research Usecase](https://youtu.be/LfZ6T8XP-Q0)| ## 👩‍💻 Contributors [![TransformerOptimus](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/133493246?v=4&w=50&h=50&mask=circle)](https://github.com/TransformerOptimus) [![Cptsnowcrasher](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/133322218?v=4&w=50&h=50&mask=circle)](https://github.com/Cptsnowcrasher) [![vectorcrow](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/133646556?v=4&w=50&h=50&mask=circle)](https://github.com/vectorcrow) [![Akki-jain](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/92881074?v=4&w=50&h=50&mask=circle)](https://github.com/Akki-jain) [![Autocop-Agent](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/129729746?v=4&w=50&h=50&mask=circle)](https://github.com/Autocop-Agent)[![COLONAYUSH](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/60507126?v=4&w=50&h=50&mask=circle)](https://github.com/COLONAYUSH)[![luciferlinx101](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/129729795?v=4&w=50&h=50&mask=circle)](https://github.com/luciferlinx101)[![mukundans89](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/101278493?v=4&w=50&h=50&mask=circle)](https://github.com/mukundans89)[![Fluder-Paradyne](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/121793617?v=4&w=50&h=50&mask=circle)](https://github.com/Fluder-Paradyne)[![nborthy](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/101320057?v=4&w=50&h=50&mask=circle)](https://github.com/nborthy)[![nihirr](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/122777244?v=4&w=50&h=50&mask=circle)](https://github.com/nihirr)[![Tarraann](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/97586318?v=4&w=50&h=50&mask=circle)](https://github.com/Tarraann)[![neelayan7](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/43145646?v=4&w=50&h=50&mask=circle)](https://github.com/neelayan7)[![Arkajit-Datta](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/61142632?v=4&w=50&h=50&mask=circle)](https://github.com/Arkajit-Datta)[![guangchen811](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/103159823?v=4&w=50&h=50&mask=circle)](https://github.com/guangchen811)[![juanfpo96](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/14787156?v=4&w=50&h=50&mask=circle)](https://github.com/juanfpo96)[![iskandarreza](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/32027019?v=4&w=50&h=50&mask=circle)](https://github.com/iskandarreza)[![jpenalbae](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/8380459?v=4&w=50&h=50&mask=circle)](https://github.com/jpenalbae)[![pallasite99](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/26508636?v=4&w=50&h=50&mask=circle)](https://github.com/pallasite99)[![xutpuu](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/11964505?v=4&w=50&h=50&mask=circle)](https://github.com/xutpuu)[![alexkreidler](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/11166947?v=4&w=50&h=50&mask=circle)](https://github.com/alexkreidler)[![hanhyalex123](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/100895608?v=4&w=50&h=50&mask=circle)](https://github.com/hanhyalex123)[![ps4vs](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/91535358?v=4&w=50&h=50&mask=circle)](https://github.com/ps4vs)[![eltociear](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/22633385?v=4&w=50&h=50&mask=circle)](https://github.com/eltociear) @@ -214,6 +195,13 @@ This project is under active development and may still have issues. We appreciat [![JPDucky](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/34105363?v=4&w=50&h=50&mask=circle)](https://github.com/JPDucky) [![Vibhusha22](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/128478691?v=4&w=50&h=50&mask=circle)](https://github.com/Vibhusha22) [![ai-akuma](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/7444521?v=4&w=50&h=50&mask=circle)](https://github.com/ai-akuma) +[![rounak610](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/81288115?v=4&w=50&h=50&mask=circle)](https://github.com/rounak610) +[![AdarshJha619](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/53672264?v=4&w=50&h=50&mask=circle)](https://github.com/AdarshJha619) +[![ResoluteStoic](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/105219157?v=4&w=50&h=50&mask=circle)](https://github.com/ResoluteStoic) +[![JohnHunt999](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/137149331?v=4&w=50&h=50&mask=circle)](https://github.com/JohnHunt999) +[![Maverick-F35](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/138012351?v=4&w=50&h=50&mask=circle)](https://github.com/Maverick-F359) +[![PaulRBerg](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/8782666?v=4&w=50&h=50&mask=circle)](https://github.com/PaulRBerg) +[![jorgectf](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/46056498?v=4&w=50&h=50&mask=circle)](https://github.com/jorgectf)

Back to top

diff --git a/gui/pages/Content/Agents/ActivityFeed.js b/gui/pages/Content/Agents/ActivityFeed.js index 4dbfb24f5..02bfb44e9 100644 --- a/gui/pages/Content/Agents/ActivityFeed.js +++ b/gui/pages/Content/Agents/ActivityFeed.js @@ -19,7 +19,7 @@ export default function ActivityFeed({selectedRunId, selectedView, setFetchedDat useEffect(() => { const interval = window.setInterval(function () { fetchFeeds(); - }, 10000); + }, 5000); return () => clearInterval(interval); }, [selectedRunId]); diff --git a/gui/pages/Content/Agents/AgentWorkspace.js b/gui/pages/Content/Agents/AgentWorkspace.js index 898bf6efb..736ac6f50 100644 --- a/gui/pages/Content/Agents/AgentWorkspace.js +++ b/gui/pages/Content/Agents/AgentWorkspace.js @@ -290,7 +290,7 @@ export default function AgentWorkspace({env, agentId, agentName, selectedView, a // } function saveAgentTemplate() { - saveAgentAsTemplate(selectedRun?.id) + saveAgentAsTemplate(agentId, selectedRun?.id ? selectedRun?.id : -1) .then((response) => { toast.success("Agent saved as template successfully", {autoClose: 1800}); }) diff --git a/gui/pages/api/DashboardService.js b/gui/pages/api/DashboardService.js index 43806c012..52782be6f 100644 --- a/gui/pages/api/DashboardService.js +++ b/gui/pages/api/DashboardService.js @@ -120,8 +120,8 @@ export const fetchAgentTemplateListLocal = () => { return api.get('/agent_templates/list?template_source=local'); }; -export const saveAgentAsTemplate = (executionId) => { - return api.post(`/agent_templates/save_agent_as_template/agent_execution_id/${executionId}`); +export const saveAgentAsTemplate = (agentId, executionId) => { + return api.post(`/agent_templates/save_agent_as_template/agent_id/${agentId}/agent_execution_id/${executionId}`); }; export const fetchAgentTemplateConfig = (templateId) => { diff --git a/requirements.txt b/requirements.txt index 65e19c2c1..554fd54ea 100644 --- a/requirements.txt +++ b/requirements.txt @@ -112,6 +112,7 @@ requests-html==0.10.0 requests-oauthlib==1.3.1 requests-toolbelt==1.0.0 s3transfer==0.6.1 +safetensors==0.3.2 sgmllib3k==1.0.0 six==1.16.0 sniffio==1.3.0 diff --git a/superagi/agent/tool_builder.py b/superagi/agent/tool_builder.py index ac4036e81..deeec5706 100644 --- a/superagi/agent/tool_builder.py +++ b/superagi/agent/tool_builder.py @@ -120,4 +120,4 @@ def set_default_params_tool(self, tool, agent_config, agent_execution_config, mo if tool.name == "QueryResourceTool": tool.description = tool.description.replace("{summary}", resource_summary) - return tool + return tool \ No newline at end of file diff --git a/superagi/controllers/agent_template.py b/superagi/controllers/agent_template.py index 0d4f5033e..7e9abb0fe 100644 --- a/superagi/controllers/agent_template.py +++ b/superagi/controllers/agent_template.py @@ -192,8 +192,9 @@ def edit_agent_template(agent_template_id: int, db.session.flush() -@router.post("/save_agent_as_template/agent_execution_id/{agent_execution_id}") +@router.post("/save_agent_as_template/agent_id/{agent_id}/agent_execution_id/{agent_execution_id}") def save_agent_as_template(agent_execution_id: str, + agent_id: str, organisation=Depends(get_user_organisation)): """ Save an agent as a template. @@ -209,44 +210,50 @@ def save_agent_as_template(agent_execution_id: str, Raises: HTTPException (status_code=404): If the agent or agent execution configurations are not found. """ + if agent_execution_id == 'undefined': raise HTTPException(status_code = 404, detail = "Agent Execution Id undefined") - - agent_executions = AgentExecution.get_agent_execution_from_id(db.session, agent_execution_id) - if agent_executions is None: - raise HTTPException(status_code = 404, detail = "Agent Execution not found") - agent_id = agent_executions.agent_id + if agent_id == 'undefined': + raise HTTPException(status_code = 404, detail = "Agent Id undefined") agent = db.session.query(Agent).filter(Agent.id == agent_id).first() if agent is None: raise HTTPException(status_code=404, detail="Agent not found") - agent_execution_configurations = db.session.query(AgentExecutionConfiguration).filter(AgentExecutionConfiguration.agent_execution_id == agent_execution_id).all() - if not agent_execution_configurations: - raise HTTPException(status_code=404, detail="Agent configurations not found") + configs = None + + if agent_execution_id == "-1": + configs = db.session.query(AgentConfiguration).filter(AgentConfiguration.agent_id == agent_id).all() + if not configs: + raise HTTPException(status_code=404, detail="Agent configurations not found") + else: + configs = db.session.query(AgentExecutionConfiguration).filter(AgentExecutionConfiguration.agent_execution_id == agent_execution_id).all() + if not configs: + raise HTTPException(status_code=404, detail="Agent execution configurations not found") + if configs is None: + raise HTTPException(status_code=404, detail="Configurations not found") + agent_template = AgentTemplate(name=agent.name, description=agent.description, agent_workflow_id=agent.agent_workflow_id, organisation_id=organisation.id) db.session.add(agent_template) db.session.commit() - main_keys = AgentTemplate.main_keys() - - for agent_execution_configuration in agent_execution_configurations: - config_value = agent_execution_configuration.value - if agent_execution_configuration.key not in main_keys: - continue - if agent_execution_configuration.key == "tools": - config_value = str(Tool.convert_tool_ids_to_names(db, eval(agent_execution_configuration.value))) - agent_template_config = AgentTemplateConfig(agent_template_id=agent_template.id, key=agent_execution_configuration.key, - value=config_value) - db.session.add(agent_template_config) + for config in configs: + config_value = config.value + if config.key not in AgentTemplate.main_keys(): + continue + if config.key == "tools": + config_value = str(Tool.convert_tool_ids_to_names(db, eval(config.value))) + agent_template_config = AgentTemplateConfig(agent_template_id=agent_template.id, key=config.key, + value=config_value) + db.session.add(agent_template_config) + db.session.commit() db.session.flush() return agent_template.to_dict() - @router.get("/list") def list_agent_templates(template_source="local", search_str="", page=0, organisation=Depends(get_user_organisation)): """ diff --git a/superagi/controllers/api/agent.py b/superagi/controllers/api/agent.py index 9fc397cca..95b35c4f1 100644 --- a/superagi/controllers/api/agent.py +++ b/superagi/controllers/api/agent.py @@ -57,7 +57,7 @@ def create_agent_with_config(agent_with_config: AgentConfigExtInput, api_key: str = Security(validate_api_key), organisation:Organisation = Depends(get_organisation_from_api_key)): project=Project.find_by_org_id(db.session, organisation.id) try: - tools_arr=Toolkit.get_tool_and_toolkit_arr(db.session,agent_with_config.tools) + tools_arr=Toolkit.get_tool_and_toolkit_arr(db.session,organisation.id,agent_with_config.tools) except Exception as e: raise HTTPException(status_code=404, detail=str(e)) @@ -177,7 +177,7 @@ def update_agent(agent_id: int, agent_with_config: AgentConfigUpdateExtInput,api raise HTTPException(status_code=409, detail="Agent is already scheduled,cannot update") try: - tools_arr=Toolkit.get_tool_and_toolkit_arr(db.session,agent_with_config.tools) + tools_arr=Toolkit.get_tool_and_toolkit_arr(db.session,organisation.id,agent_with_config.tools) except Exception as e: raise HTTPException(status_code=404,detail=str(e)) diff --git a/superagi/jobs/agent_executor.py b/superagi/jobs/agent_executor.py index cd3f8d99b..8ff0977b2 100644 --- a/superagi/jobs/agent_executor.py +++ b/superagi/jobs/agent_executor.py @@ -96,7 +96,7 @@ def execute_next_step(self, agent_execution_id): logger.info("Agent Execution is completed or waiting for permission") session.close() return - superagi.worker.execute_agent.apply_async((agent_execution_id, datetime.now()), countdown=10) + superagi.worker.execute_agent.apply_async((agent_execution_id, datetime.now()), countdown=2) # superagi.worker.execute_agent.delay(agent_execution_id, datetime.now()) finally: session.close() diff --git a/superagi/models/toolkit.py b/superagi/models/toolkit.py index 91f2a532a..1707d9810 100644 --- a/superagi/models/toolkit.py +++ b/superagi/models/toolkit.py @@ -140,12 +140,12 @@ def fetch_tool_ids_from_toolkit(cls, session, toolkit_ids): return agent_toolkit_tools @classmethod - def get_tool_and_toolkit_arr(cls, session, agent_config_tools_arr: list): + def get_tool_and_toolkit_arr(cls, session, organisation_id :int,agent_config_tools_arr: list): from superagi.models.tool import Tool toolkits_arr= set() tools_arr= set() for tool_obj in agent_config_tools_arr: - toolkit=session.query(Toolkit).filter(Toolkit.name == tool_obj["name"].strip()).first() + toolkit=session.query(Toolkit).filter(Toolkit.name == tool_obj["name"].strip(), Toolkit.organisation_id == organisation_id).first() if toolkit is None: raise Exception("One or more of the Tool(s)/Toolkit(s) does not exist.") toolkits_arr.add(toolkit.id) diff --git a/tests/unit_tests/controllers/test_toolkit.py b/tests/unit_tests/controllers/test_toolkit.py index ed9dcc353..68aef8c88 100644 --- a/tests/unit_tests/controllers/test_toolkit.py +++ b/tests/unit_tests/controllers/test_toolkit.py @@ -2,11 +2,12 @@ import pytest from fastapi.testclient import TestClient -from superagi.types.key_type import ToolConfigKeyType + from main import app from superagi.models.organisation import Organisation from superagi.models.tool import Tool from superagi.models.tool_config import ToolConfig +from superagi.types.key_type import ToolConfigKeyType from superagi.models.toolkit import Toolkit client = TestClient(app) @@ -87,7 +88,6 @@ def mock_toolkit_details(): { "key": "config_key_1", "value": "config_value_1", - "value": "config_value_1", 'key_type': ToolConfigKeyType.STRING, 'is_secret': True, 'is_required': False @@ -98,6 +98,7 @@ def mock_toolkit_details(): 'key_type': ToolConfigKeyType.FILE, 'is_secret': True, 'is_required': False + } ] } diff --git a/tests/unit_tests/models/test_toolkit.py b/tests/unit_tests/models/test_toolkit.py index 339c970c9..297ef8716 100644 --- a/tests/unit_tests/models/test_toolkit.py +++ b/tests/unit_tests/models/test_toolkit.py @@ -259,7 +259,7 @@ def test_get_tool_and_toolkit_arr_with_nonexistent_toolkit(): # Use a context manager to capture the raised exception and its message with pytest.raises(Exception) as exc_info: - Toolkit.get_tool_and_toolkit_arr(session, agent_config_tools_arr) + Toolkit.get_tool_and_toolkit_arr(session,1, agent_config_tools_arr) # Assert that the expected error message is contained within the raised exception message expected_error_message = "One or more of the Tool(s)/Toolkit(s) does not exist."