swarms agents tools -> swarms.tools

Former-commit-id: d5a0227e62
group-chat
Kye 1 year ago
parent 02d62d396f
commit 4b86d795ce

@ -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

@ -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,

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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__)

@ -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
# from swarms.tools.developer import Terminal, CodeEditor

@ -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()

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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,

@ -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,

@ -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,

@ -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,

@ -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,

@ -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(

@ -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:

Loading…
Cancel
Save