From 05719c1dc92b7cfb0ddea4873e38058b2356eeaa Mon Sep 17 00:00:00 2001 From: rakesh-krishna-a-s Date: Mon, 28 Aug 2023 13:07:11 +0530 Subject: [PATCH 1/5] expose port --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) 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 From 54caf011a61d87b966b7cbaf01c9f5324eb5aea2 Mon Sep 17 00:00:00 2001 From: Fluder-Paradyne <121793617+Fluder-Paradyne@users.noreply.github.com> Date: Mon, 28 Aug 2023 13:38:55 +0530 Subject: [PATCH 2/5] latest safetensors breaking in macs (#1134) --- requirements.txt | 1 + 1 file changed, 1 insertion(+) 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 From b75487325c78d11796ddaea4aa39006902b74863 Mon Sep 17 00:00:00 2001 From: Rounak Bhatia Date: Mon, 28 Aug 2023 15:55:38 +0530 Subject: [PATCH 3/5] Changes in save template (#1120) * fix * changes in save template * changes in save template * bug fixes * changes in save template * changes in save template --------- Co-authored-by: Rounak Bhatia Co-authored-by: namansleeps --- gui/pages/Content/Agents/AgentWorkspace.js | 2 +- gui/pages/api/DashboardService.js | 4 +- superagi/controllers/agent_template.py | 49 ++++++++++++---------- 3 files changed, 31 insertions(+), 24 deletions(-) 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/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)): """ From 50dbec295e6abd2291b85d066651b605d8639744 Mon Sep 17 00:00:00 2001 From: Abhijeet <129729795+luciferlinx101@users.noreply.github.com> Date: Mon, 28 Aug 2023 18:47:04 +0530 Subject: [PATCH 4/5] Main to dev sync (#1139) --- README.MD | 48 ++++++++------------ gui/pages/Content/Agents/ActivityFeed.js | 2 +- superagi/agent/tool_builder.py | 2 +- superagi/controllers/api/agent.py | 4 +- superagi/jobs/agent_executor.py | 2 +- superagi/models/toolkit.py | 4 +- tests/unit_tests/controllers/test_toolkit.py | 5 +- tests/unit_tests/models/test_toolkit.py | 2 +- 8 files changed, 29 insertions(+), 40 deletions(-) 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/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/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 c69f5bb04..faf1ccc48 100644 --- a/superagi/jobs/agent_executor.py +++ b/superagi/jobs/agent_executor.py @@ -99,7 +99,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." From 737268b557e8658992d4192324987437f15ff363 Mon Sep 17 00:00:00 2001 From: Kalki <97698934+jedan2506@users.noreply.github.com> Date: Mon, 28 Aug 2023 18:58:18 +0530 Subject: [PATCH 5/5] Models fixes (#1126) * Models Frontend Changes * Models Frontend Changes * Models Frontend Changes * Backend Compatibility for New/Existing users on local * DEV api key requirements * removing print statements * removing print statements * removing print statements * removing print statements * backend compatibility * backend compatibility * backend compatibility --- gui/pages/Content/Agents/AgentCreate.js | 8 +++--- .../agent/agent_iteration_step_handler.py | 1 - superagi/agent/agent_tool_step_handler.py | 1 - superagi/jobs/agent_executor.py | 6 ----- superagi/models/models.py | 27 +++++++++++++++++++ superagi/models/models_config.py | 9 ++++--- tests/unit_tests/models/test_models_config.py | 12 +++++++++ 7 files changed, 49 insertions(+), 15 deletions(-) diff --git a/gui/pages/Content/Agents/AgentCreate.js b/gui/pages/Content/Agents/AgentCreate.js index 95f731786..4d2849042 100644 --- a/gui/pages/Content/Agents/AgentCreate.js +++ b/gui/pages/Content/Agents/AgentCreate.js @@ -11,7 +11,7 @@ import { updateExecution, uploadFile, getAgentDetails, addAgentRun, fetchModels, - getAgentWorkflows + getAgentWorkflows, validateOrAddModels } from "@/pages/api/DashboardService"; import { formatBytes, @@ -56,7 +56,7 @@ export default function AgentCreate({ const [searchValue, setSearchValue] = useState(''); const [showButton, setShowButton] = useState(false); const [showPlaceholder, setShowPlaceholder] = useState(true); - const [modelsArray, setModelsArray] = useState([]); + const [modelsArray, setModelsArray] = useState(['gpt-4', 'gpt-3.5-turbo', 'gpt-3.5-turbo-16k']); const constraintsArray = [ "If you are unsure how you previously did something or want to recall past events, thinking about similar events will help you remember.", @@ -69,7 +69,7 @@ export default function AgentCreate({ const [goals, setGoals] = useState(['Describe the agent goals here']); const [instructions, setInstructions] = useState(['']); - const models = ['gpt-4', 'gpt-3.5-turbo', 'gpt-3.5-turbo-16k', 'gpt-4-32k', 'google-palm-bison-001', 'replicate-llama13b-v2-chat'] + const models = ['gpt-4', 'gpt-3.5-turbo', 'gpt-3.5-turbo-16k'] const [model, setModel] = useState(models[1]); const modelRef = useRef(null); const [modelDropdown, setModelDropdown] = useState(false); @@ -494,7 +494,7 @@ export default function AgentCreate({ return true; } - const handleAddAgent = () => { + const handleAddAgent = async () => { if (!validateAgentData(true)) { return; } diff --git a/superagi/agent/agent_iteration_step_handler.py b/superagi/agent/agent_iteration_step_handler.py index 94e50c3e9..543a285e6 100644 --- a/superagi/agent/agent_iteration_step_handler.py +++ b/superagi/agent/agent_iteration_step_handler.py @@ -34,7 +34,6 @@ class AgentIterationStepHandler: """ Handles iteration workflow steps in the agent workflow.""" def __init__(self, session, llm, agent_id: int, agent_execution_id: int, memory=None): - print(session, llm, agent_execution_id, agent_id, memory) self.session = session self.llm = llm self.agent_execution_id = agent_execution_id diff --git a/superagi/agent/agent_tool_step_handler.py b/superagi/agent/agent_tool_step_handler.py index 52951a00d..7aeb0d59b 100644 --- a/superagi/agent/agent_tool_step_handler.py +++ b/superagi/agent/agent_tool_step_handler.py @@ -99,7 +99,6 @@ def _process_input_instruction(self, agent_config, agent_execution_config, step_ prompt = self._build_tool_input_prompt(step_tool, tool_obj, agent_execution_config) logger.info("Prompt: ", prompt) agent_feeds = AgentExecutionFeed.fetch_agent_execution_feeds(self.session, self.agent_execution_id) - print(".........//////////////..........1") messages = AgentLlmMessageBuilder(self.session, self.llm, self.llm.get_model(), self.agent_id, self.agent_execution_id) \ .build_agent_messages(prompt, agent_feeds, history_enabled=step_tool.history_enabled, completion_prompt=step_tool.completion_prompt) diff --git a/superagi/jobs/agent_executor.py b/superagi/jobs/agent_executor.py index faf1ccc48..8ff0977b2 100644 --- a/superagi/jobs/agent_executor.py +++ b/superagi/jobs/agent_executor.py @@ -56,7 +56,6 @@ def execute_next_step(self, agent_execution_id): return model_config = AgentConfiguration.get_model_api_key(session, agent_execution.agent_id, agent_config["model"]) - print(model_config) model_api_key = model_config['api_key'] model_llm_source = model_config['provider'] try: @@ -72,8 +71,6 @@ def execute_next_step(self, agent_execution_id): agent_workflow_step = session.query(AgentWorkflowStep).filter( AgentWorkflowStep.id == agent_execution.current_agent_step_id).first() try: - print(agent_config["model"]) - print(model_api_key) if agent_workflow_step.action_type == "TOOL": tool_step_handler = AgentToolStepHandler(session, llm=get_model(model=agent_config["model"], api_key=model_api_key, organisation_id=organisation.id) @@ -107,9 +104,6 @@ def execute_next_step(self, agent_execution_id): @classmethod def get_embedding(cls, model_source, model_api_key): - print("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&") - print(model_source) - print(model_api_key) if "OpenAI" in model_source: return OpenAiEmbedding(api_key=model_api_key) if "Google" in model_source: diff --git a/superagi/models/models.py b/superagi/models/models.py index d024c842f..35c0e9303 100644 --- a/superagi/models/models.py +++ b/superagi/models/models.py @@ -2,6 +2,8 @@ from sqlalchemy.sql import func from typing import List, Dict, Union from superagi.models.base_model import DBBaseModel +from superagi.llms.openai import OpenAi +from superagi.helper.encyption_helper import decrypt_data import requests, logging # marketplace_url = "https://app.superagi.com/api" @@ -153,6 +155,31 @@ def store_model_details(cls, session, organisation_id, model_name, description, def fetch_models(cls, session, organisation_id) -> Union[Dict[str, str], List[Dict[str, Union[str, int]]]]: try: from superagi.models.models_config import ModelsConfig + from superagi.models.configuration import Configuration + + model_provider = session.query(ModelsConfig).filter(ModelsConfig.provider == "OpenAI", + ModelsConfig.org_id == organisation_id).first() + if model_provider is None: + configurations = session.query(Configuration).filter(Configuration.key == 'model_api_key', + Configuration.organisation_id == organisation_id).first() + + if configurations is None: + return {"error": "API Key is Missing"} + else: + default_models = {"gpt-3.5-turbo": 4032, "gpt-4": 8092, "gpt-3.5-turbo-16k": 16184} + model_api_key = decrypt_data(configurations.value) + + model_details = ModelsConfig.store_api_key(session, organisation_id, "OpenAI", model_api_key) + model_provider_id = model_details.get('model_provider_id') + models = OpenAi(api_key=model_api_key).get_models() + + installed_models = [model[0] for model in session.query(Models.model_name).filter(Models.org_id == organisation_id).all()] + + for model in models: + if model not in installed_models and model in default_models: + result = cls.store_model_details(session, organisation_id, model, model, '', + model_provider_id, default_models[model], 'Custom', '') + models = session.query(Models.id, Models.model_name, Models.description, ModelsConfig.provider).join( ModelsConfig, Models.model_provider_id == ModelsConfig.id).filter( Models.org_id == organisation_id).all() diff --git a/superagi/models/models_config.py b/superagi/models/models_config.py index a8d2a2ba6..fc4bad9e3 100644 --- a/superagi/models/models_config.py +++ b/superagi/models/models_config.py @@ -76,14 +76,17 @@ def store_api_key(cls, session, organisation_id, model_provider, model_api_key): ModelsConfig.provider == model_provider)).first() if existing_entry: existing_entry.api_key = encrypt_data(model_api_key) + session.commit() + result = {'message': 'The API key was successfully updated'} else: new_entry = ModelsConfig(org_id=organisation_id, provider=model_provider, api_key=encrypt_data(model_api_key)) session.add(new_entry) + session.commit() + session.flush() + result = {'message': 'The API key was successfully stored', 'model_provider_id': new_entry.id} - session.commit() - - return {'message': 'The API key was successfully stored'} + return result @classmethod def fetch_api_keys(cls, session, organisation_id): diff --git a/tests/unit_tests/models/test_models_config.py b/tests/unit_tests/models/test_models_config.py index 56bfd89c0..5c1731d3a 100644 --- a/tests/unit_tests/models/test_models_config.py +++ b/tests/unit_tests/models/test_models_config.py @@ -111,4 +111,16 @@ def test_fetch_model_by_id(mock_session): # Call the method model = ModelsConfig.fetch_model_by_id(mock_session, organisation_id, model_provider_id) + assert model == {"provider": "some_provider"} + +def test_fetch_model_by_id_marketplace(mock_session): + # Arrange + model_provider_id = 1 + # Mock model + mock_model = MagicMock() + mock_model.provider = 'some_provider' + mock_session.query.return_value.filter.return_value.first.return_value = mock_model + + # Call the method + model = ModelsConfig.fetch_model_by_id_marketplace(mock_session, model_provider_id) assert model == {"provider": "some_provider"} \ No newline at end of file