diff --git a/DOCS/workers/WorkerNode.md b/DOCS/workers/WorkerNode.md index 39283840..b9033bdc 100644 --- a/DOCS/workers/WorkerNode.md +++ b/DOCS/workers/WorkerNode.md @@ -62,7 +62,7 @@ Copy code ``` -from swarms.agents.tools.autogpt import DuckDuckGoSearchRun +from swarms.tools.autogpt import DuckDuckGoSearchRun worker_node_initializer = WorkerNodeInitializer(openai_api_key="your_openai_api_key", @@ -212,7 +212,7 @@ Here is a full example of how to use the `WorkerNode` and `WorkerNodeInitiali ```python -from swarms.agents.tools.autogpt import DuckDuckGoSearchRun +from swarms.tools.autogpt import DuckDuckGoSearchRun from swarms.worker_node import WorkerNode, WorkerNodeInitializer diff --git a/api/olds/container.py b/api/olds/container.py index 2ea88f33..a240e4c1 100644 --- a/api/olds/container.py +++ b/api/olds/container.py @@ -6,11 +6,11 @@ from fastapi.templating import Jinja2Templates from swarms.agents.utils.agent_creator import AgentManager from swarms.utils.main import BaseHandler, FileHandler, FileType -from swarms.agents.tools.main import ExitConversation, RequestsGet, CodeEditor, Terminal +from swarms.tools.main import ExitConversation, RequestsGet, CodeEditor, Terminal from swarms.utils.main import CsvToDataframe -from swarms.agents.tools.main import BaseToolSet +from swarms.tools.main import BaseToolSet from swarms.utils.main import StaticUploader @@ -30,8 +30,8 @@ if os.environ["USE_GPU"]: import torch # from core.handlers.image import ImageCaptioning - from swarms.agents.tools.main import ImageCaptioning - from swarms.agents.tools.main import ( + from swarms.tools.main import ImageCaptioning + from swarms.tools.main import ( ImageEditing, InstructPix2Pix, Text2Image, diff --git a/swarms/agents/__init__.py b/swarms/agents/__init__.py index 32d65d8e..7ec8f5ce 100644 --- a/swarms/agents/__init__.py +++ b/swarms/agents/__init__.py @@ -1,21 +1,14 @@ """Agent Infrastructure, models, memory, utils, tools""" -#models -from swarms.agents.models.anthropic import Anthropic -from swarms.agents.models.huggingface import HuggingFaceLLM -# from swarms.agents.models.palm import GooglePalm -from swarms.agents.models.petals import Petals -from swarms.agents.models.openai import OpenAI - ########### # #tools -# from swarms.agents.tools.base import BaseTool, Tool, StructuredTool, ToolWrapper, BaseToolSet, ToolCreator, GlobalToolsCreator, SessionToolsCreator, ToolsFactory -# from swarms.agents.tools.autogpt import pushd, process_csv, async_load_playwright, run_async, browse_web_page, WebpageQATool, web_search, query_website_tool -# from swarms.agents.tools.exit_conversation import ExitConversation +# from swarms.tools.base import BaseTool, Tool, StructuredTool, ToolWrapper, BaseToolSet, ToolCreator, GlobalToolsCreator, SessionToolsCreator, ToolsFactory +# from swarms.tools.autogpt import pushd, process_csv, async_load_playwright, run_async, browse_web_page, WebpageQATool, web_search, query_website_tool +# from swarms.tools.exit_conversation import ExitConversation -# from swarms.agents.tools.models import MaskFormer, ImageEditing, InstructPix2Pix, Text2Image, VisualQuestionAnswering, ImageCaptioning -# from swarms.agents.tools.file_mangagement import read_tool, write_tool, list_tool -# from swarms.agents.tools.requests import RequestsGet +# from swarms.tools.models import MaskFormer, ImageEditing, InstructPix2Pix, Text2Image, VisualQuestionAnswering, ImageCaptioning +# from swarms.tools.file_mangagement import read_tool, write_tool, list_tool +# from swarms.tools.requests import RequestsGet -# from swarms.agents.tools.developer import Terminal, CodeEditor +# from swarms.tools.developer import Terminal, CodeEditor diff --git a/swarms/agents/agent.py b/swarms/agents/agent.py index ac21b9f1..b61c9874 100644 --- a/swarms/agents/agent.py +++ b/swarms/agents/agent.py @@ -4,21 +4,21 @@ from typing import List, Optional from langchain.chains.llm import LLMChain -from swarms.agents.memory.base import VectorStoreRetriever -from swarms.agents.memory.base_memory import BaseChatMessageHistory, ChatMessageHistory -from swarms.agents.memory.document import Document -from swarms.agents.models.base import AbstractModel -from swarms.agents.models.prompts.agent_prompt_auto import ( +from swarms.memory.base import VectorStoreRetriever +from swarms.memory.base_memory import BaseChatMessageHistory, ChatMessageHistory +from swarms.memory.document import Document +from swarms.models.base import AbstractModel +from swarms.models.prompts.agent_prompt_auto import ( MessageFormatter, PromptConstructor, ) -from swarms.agents.models.prompts.agent_prompt_generator import FINISH_NAME -from swarms.agents.models.prompts.base import ( +from swarms.models.prompts.agent_prompt_generator import FINISH_NAME +from swarms.models.prompts.base import ( AIMessage, HumanMessage, SystemMessage, ) -from swarms.agents.tools.base import BaseTool +from swarms.tools.base import BaseTool from swarms.agents.utils.Agent import AgentOutputParser from swarms.agents.utils.human_input import HumanInputRun diff --git a/swarms/agents/memory.py b/swarms/agents/memory.py index 6880eb77..daac8da6 100644 --- a/swarms/agents/memory.py +++ b/swarms/agents/memory.py @@ -1,7 +1,7 @@ from typing import Any, Dict, List -from swarms.agents.memory.base_memory import BaseChatMemory, get_prompt_input_key -from swarms.agents.memory.base import VectorStoreRetriever +from swarms.memory.base_memory import BaseChatMemory, get_prompt_input_key +from swarms.memory.base import VectorStoreRetriever class AgentMemory(BaseChatMemory): retriever: VectorStoreRetriever diff --git a/swarms/agents/utils/agent_creator.py b/swarms/agents/utils/agent_creator.py index fc7bacfd..ab40400f 100644 --- a/swarms/agents/utils/agent_creator.py +++ b/swarms/agents/utils/agent_creator.py @@ -5,7 +5,7 @@ from langchain.agents.agent import AgentExecutor from langchain.callbacks.manager import CallbackManager from langchain.chains.conversation.memory import ConversationBufferMemory from langchain.memory.chat_memory import BaseChatMemory -from swarms.agents.tools.main import BaseToolSet, ToolsFactory +from swarms.tools.main import BaseToolSet, ToolsFactory from swarms.agents.utils.agent_setup import AgentSetup from swarms.agents.utils.Calback import EVALCallbackHandler, ExecutionTracingCallbackHandler diff --git a/swarms/agents/utils/agent_setup.py b/swarms/agents/utils/agent_setup.py index ad6b4c44..2f0a7f2f 100644 --- a/swarms/agents/utils/agent_setup.py +++ b/swarms/agents/utils/agent_setup.py @@ -8,7 +8,7 @@ from langchain.chat_models.base import BaseChatModel from langchain.schema import BaseOutputParser from swarms.agents.models.prompts.prebuild.multi_modal_prompts import EVAL_PREFIX, EVAL_SUFFIX -from swarms.agents.tools.main import BaseToolSet, ToolsFactory +from swarms.tools.main import BaseToolSet, ToolsFactory from .ConversationalChatAgent import ConversationalChatAgent from .output_parser import EvalOutputParser diff --git a/swarms/models/__init__.py b/swarms/models/__init__.py index e69de29b..d5c4ed27 100644 --- a/swarms/models/__init__.py +++ b/swarms/models/__init__.py @@ -0,0 +1,5 @@ +from swarms.models.anthropic import Anthropic +from swarms.models.huggingface import HuggingFaceLLM +# from swarms.models.palm import GooglePalm +from swarms.models.petals import Petals +from swarms.models.openai import OpenAI diff --git a/swarms/models/huggingface.py b/swarms/models/huggingface.py index fe88ea58..9fd795c3 100644 --- a/swarms/models/huggingface.py +++ b/swarms/models/huggingface.py @@ -9,7 +9,7 @@ class HuggingFaceLLM: model_id: str, device: str = None, max_length: int = 20, - quantize: bool = False, + # quantize: bool = False, quantization_config: dict = None ): self.logger = logging.getLogger(__name__) diff --git a/swarms/tools/__init__.py b/swarms/tools/__init__.py index 08a6c286..f86633c0 100644 --- a/swarms/tools/__init__.py +++ b/swarms/tools/__init__.py @@ -1,9 +1,9 @@ -# from swarms.agents.tools.base import BaseTool, Tool, StructuredTool, ToolWrapper, BaseToolSet, ToolCreator, GlobalToolsCreator, SessionToolsCreator, ToolsFactory -# from swarms.agents.tools.autogpt import pushd, process_csv, async_load_playwright, run_async, browse_web_page, WebpageQATool, web_search, query_website_tool -# from swarms.agents.tools.exit_conversation import ExitConversation +# from swarms.tools.base import BaseTool, Tool, StructuredTool, ToolWrapper, BaseToolSet, ToolCreator, GlobalToolsCreator, SessionToolsCreator, ToolsFactory +# from swarms.tools.autogpt import pushd, process_csv, async_load_playwright, run_async, browse_web_page, WebpageQATool, web_search, query_website_tool +# from swarms.tools.exit_conversation import ExitConversation -# from swarms.agents.tools.models import MaskFormer, ImageEditing, InstructPix2Pix, Text2Image, VisualQuestionAnswering, ImageCaptioning -# from swarms.agents.tools.file_mangagement import read_tool, write_tool, list_tool -# from swarms.agents.tools.requests import RequestsGet +# from swarms.tools.models import MaskFormer, ImageEditing, InstructPix2Pix, Text2Image, VisualQuestionAnswering, ImageCaptioning +# from swarms.tools.file_mangagement import read_tool, write_tool, list_tool +# from swarms.tools.requests import RequestsGet -# from swarms.agents.tools.developer import Terminal, CodeEditor \ No newline at end of file +# from swarms.tools.developer import Terminal, CodeEditor \ No newline at end of file diff --git a/swarms/tools/autogpt.py b/swarms/tools/autogpt.py index af471449..72ad4a41 100644 --- a/swarms/tools/autogpt.py +++ b/swarms/tools/autogpt.py @@ -136,7 +136,7 @@ query_website_tool = WebpageQATool(qa_chain=load_qa_with_sources_chain(llm)) -# from swarms.agents.tools.code_intepretor import CodeInterpreter +# from swarms.tools.code_intepretor import CodeInterpreter # # @tool # code_intepret = CodeInterpreter() diff --git a/swarms/tools/code_intepretor.py b/swarms/tools/code_intepretor.py index 679fca8e..5af3e46a 100644 --- a/swarms/tools/code_intepretor.py +++ b/swarms/tools/code_intepretor.py @@ -1,5 +1,5 @@ #props to shroominic -from swarms.agents.tools.base import Tool, ToolException +from swarms.tools.base import Tool, ToolException from typing import Callable, Any, List from codeinterpreterapi import CodeInterpreterSession, File, ToolException diff --git a/swarms/tools/developer.py b/swarms/tools/developer.py index 192b947f..f373e5f3 100644 --- a/swarms/tools/developer.py +++ b/swarms/tools/developer.py @@ -20,7 +20,7 @@ from ptrace.func_call import FunctionCallOptions from ptrace.syscall import PtraceSyscall from ptrace.tools import signal_to_exitcode -from swarms.agents.tools.base import BaseToolSet, SessionGetter, ToolScope, tool +from swarms.tools.base import BaseToolSet, SessionGetter, ToolScope, tool from swarms.utils.logger import logger from swarms.utils.main import ANSI, Color, Style # test diff --git a/swarms/tools/exit_conversation.py b/swarms/tools/exit_conversation.py index 2476a023..ffb78458 100644 --- a/swarms/tools/exit_conversation.py +++ b/swarms/tools/exit_conversation.py @@ -1,6 +1,6 @@ from langchain.tools import tool -from swarms.agents.tools.base import BaseToolSet, SessionGetter, ToolScope +from swarms.tools.base import BaseToolSet, SessionGetter, ToolScope from swarms.utils.logger import logger diff --git a/swarms/tools/models.py b/swarms/tools/models.py index e8aaff6b..b8d06d1d 100644 --- a/swarms/tools/models.py +++ b/swarms/tools/models.py @@ -19,8 +19,8 @@ from transformers import ( ) from swarms.agents.models.prompts.prebuild.multi_modal_prompts import IMAGE_PROMPT -from swarms.agents.tools.base import tool -from swarms.agents.tools.main import BaseToolSet +from swarms.tools.base import tool +from swarms.tools.main import BaseToolSet from swarms.utils.logger import logger from swarms.utils.main import BaseHandler, get_new_image_name diff --git a/swarms/tools/requests.py b/swarms/tools/requests.py index 4c76b454..ff0c0d6d 100644 --- a/swarms/tools/requests.py +++ b/swarms/tools/requests.py @@ -2,7 +2,7 @@ import requests from bs4 import BeautifulSoup -from swarms.agents.tools.base import BaseToolSet, tool +from swarms.tools.base import BaseToolSet, tool from swarms.utils.logger import logger diff --git a/swarms/workers/autobot.py b/swarms/workers/autobot.py index aaa0d082..15c3a9b8 100644 --- a/swarms/workers/autobot.py +++ b/swarms/workers/autobot.py @@ -5,7 +5,7 @@ from langchain.embeddings import OpenAIEmbeddings from langchain.vectorstores import FAISS from langchain_experimental.autonomous_agents import AutoGPT -from swarms.agents.tools.autogpt import ( +from swarms.tools.autogpt import ( DuckDuckGoSearchRun, FileChatMessageHistory, ReadFileTool, diff --git a/swarms/workers/vortex_worker.py b/swarms/workers/vortex_worker.py index eac428dd..a35e39c4 100644 --- a/swarms/workers/vortex_worker.py +++ b/swarms/workers/vortex_worker.py @@ -14,7 +14,7 @@ from langchain.embeddings import OpenAIEmbeddings from langchain.vectorstores import FAISS from langchain_experimental.autonomous_agents import AutoGPT -from swarms.agents.tools.autogpt import ( +from swarms.tools.autogpt import ( FileChatMessageHistory, ReadFileTool, WebpageQATool, diff --git a/swarms/workers/worker.py b/swarms/workers/worker.py index 1443d9a0..3ce98676 100644 --- a/swarms/workers/worker.py +++ b/swarms/workers/worker.py @@ -6,7 +6,7 @@ from langchain.tools.human.tool import HumanInputRun from langchain.vectorstores import FAISS from langchain_experimental.autonomous_agents import AutoGPT -from swarms.agents.tools.autogpt import ( +from swarms.tools.autogpt import ( ReadFileTool, WriteFileTool, process_csv, diff --git a/swarms/workers/worker_agent_ultra.py b/swarms/workers/worker_agent_ultra.py index 34c9a9a6..27c182f3 100644 --- a/swarms/workers/worker_agent_ultra.py +++ b/swarms/workers/worker_agent_ultra.py @@ -14,7 +14,7 @@ from typing import Dict, List from langchain.memory.chat_message_histories import FileChatMessageHistory -from swarms.agents.tools.main import ( +from swarms.tools.main import ( BaseToolSet, CodeEditor, ExitConversation, @@ -110,7 +110,7 @@ class WorkerUltraNodeInitializer: if os.environ.get("USE_GPU", False): import torch - from swarms.agents.tools.main import ( + from swarms.tools.main import ( ImageCaptioning, ImageEditing, InstructPix2Pix, diff --git a/swarms/workers/worker_node.py b/swarms/workers/worker_node.py index 28077552..2764768e 100644 --- a/swarms/workers/worker_node.py +++ b/swarms/workers/worker_node.py @@ -9,7 +9,7 @@ from langchain.embeddings import OpenAIEmbeddings from langchain.vectorstores import FAISS from langchain_experimental.autonomous_agents import AutoGPT -from swarms.agents.tools.autogpt import ( +from swarms.tools.autogpt import ( DuckDuckGoSearchRun, FileChatMessageHistory, ReadFileTool, @@ -19,7 +19,7 @@ from swarms.agents.tools.autogpt import ( process_csv, # web_search, ) -# from swarms.agents.tools.developer import ( +# from swarms.tools.developer import ( # code_editor_append, # code_editor_delete, # code_editor_patch, diff --git a/swarms/workers/worker_ultra_node.py b/swarms/workers/worker_ultra_node.py index c6c07390..c9331bba 100644 --- a/swarms/workers/worker_ultra_node.py +++ b/swarms/workers/worker_ultra_node.py @@ -6,9 +6,9 @@ from typing import Dict, List from swarms.agents.utils.agent_creator import AgentCreator from swarms.utils.main import BaseHandler, FileHandler, FileType -from swarms.agents.tools.main import ExitConversation, RequestsGet, CodeEditor, Terminal +from swarms.tools.main import ExitConversation, RequestsGet, CodeEditor, Terminal from swarms.utils.main import CsvToDataframe -from swarms.agents.tools.main import BaseToolSet +from swarms.tools.main import BaseToolSet from swarms.utils.main import StaticUploader logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') @@ -45,8 +45,8 @@ class WorkerUltraNode: if os.environ.get("USE_GPU", False): import torch - from swarms.agents.tools.main import ImageCaptioning - from swarms.agents.tools.main import ImageEditing, InstructPix2Pix, Text2Image, VisualQuestionAnswering + from swarms.tools.main import ImageCaptioning + from swarms.tools.main import ImageEditing, InstructPix2Pix, Text2Image, VisualQuestionAnswering if torch.cuda.is_available(): toolsets.extend( diff --git a/tests/boss/boss_node.py b/tests/boss/boss_node.py index 1982b810..9414a947 100644 --- a/tests/boss/boss_node.py +++ b/tests/boss/boss_node.py @@ -1,6 +1,6 @@ import pytest from unittest.mock import Mock, patch -from swarms.agents.tools.agent_tools import * +from swarms.tools.agent_tools import * from swarms.boss.boss_node import BossNodeInitializer, BossNode # For initializing BossNodeInitializer in multiple tests @pytest.fixture @@ -17,15 +17,15 @@ def mock_boss_node_initializer(): # Test BossNodeInitializer class __init__ method def test_boss_node_initializer_init(mock_boss_node_initializer): - with patch('swarms.agents.tools.agent_tools.BabyAGI.from_llm') as mock_from_llm: + with patch('swarms.tools.agent_tools.BabyAGI.from_llm') as mock_from_llm: assert isinstance(mock_boss_node_initializer, BossNodeInitializer) mock_from_llm.assert_called_once() # Test initialize_vectorstore method of BossNodeInitializer class def test_boss_node_initializer_initialize_vectorstore(mock_boss_node_initializer): - with patch('swarms.agents.tools.agent_tools.OpenAIEmbeddings') as mock_embeddings, \ - patch('swarms.agents.tools.agent_tools.FAISS') as mock_faiss: + with patch('swarms.tools.agent_tools.OpenAIEmbeddings') as mock_embeddings, \ + patch('swarms.tools.agent_tools.FAISS') as mock_faiss: result = mock_boss_node_initializer.initialize_vectorstore() mock_embeddings.assert_called_once() @@ -35,7 +35,7 @@ def test_boss_node_initializer_initialize_vectorstore(mock_boss_node_initializer # Test initialize_llm method of BossNodeInitializer class def test_boss_node_initializer_initialize_llm(mock_boss_node_initializer): - with patch('swarms.agents.tools.agent_tools.OpenAI') as mock_llm: + with patch('swarms.tools.agent_tools.OpenAI') as mock_llm: result = mock_boss_node_initializer.initialize_llm(mock_llm) mock_llm.assert_called_once() assert result is not None @@ -75,12 +75,12 @@ def test_boss_node_initializer_run(task, mock_boss_node_initializer): ('valid_key', 'valid_objective', OpenAI, 0)]) def test_boss_node(api_key, objective, llm_class, max_iterations): with patch('os.getenv') as mock_getenv, \ - patch('swarms.agents.tools.agent_tools.PromptTemplate.from_template') as mock_from_template, \ - patch('swarms.agents.tools.agent_tools.LLMChain') as mock_llm_chain, \ - patch('swarms.agents.tools.agent_tools.ZeroShotAgent.create_prompt') as mock_create_prompt, \ - patch('swarms.agents.tools.agent_tools.ZeroShotAgent') as mock_zero_shot_agent, \ - patch('swarms.agents.tools.agent_tools.AgentExecutor.from_agent_and_tools') as mock_from_agent_and_tools, \ - patch('swarms.agents.tools.agent_tools.BossNodeInitializer') as mock_boss_node_initializer, \ + patch('swarms.tools.agent_tools.PromptTemplate.from_template') as mock_from_template, \ + patch('swarms.tools.agent_tools.LLMChain') as mock_llm_chain, \ + patch('swarms.tools.agent_tools.ZeroShotAgent.create_prompt') as mock_create_prompt, \ + patch('swarms.tools.agent_tools.ZeroShotAgent') as mock_zero_shot_agent, \ + patch('swarms.tools.agent_tools.AgentExecutor.from_agent_and_tools') as mock_from_agent_and_tools, \ + patch('swarms.tools.agent_tools.BossNodeInitializer') as mock_boss_node_initializer, \ patch.object(mock_boss_node_initializer, 'create_task') as mock_create_task, \ patch.object(mock_boss_node_initializer, 'run') as mock_run: