__init__ imports for tools to seamlessly import

Former-commit-id: 6a335b0c2e
pull/47/head
Kye 2 years ago
parent bc43b48e70
commit 0fcdfa3c59

@ -6,4 +6,12 @@
#tools #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
from swarms.agents.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.agents.tools.developer import Terminal, CodeEditor

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

@ -781,23 +781,23 @@ class CodeEditor(BaseToolSet):
) )
return output return output
# @tool( @tool(
# name="CodeEditor.PATCH", name="CodeEditor.PATCH",
# description="Patch the code to correct the error if an error occurs or to improve it. " description="Patch the code to correct the error if an error occurs or to improve it. "
# "Input is a list of patches. The patch is separated by {seperator}. ".format( "Input is a list of patches. The patch is separated by {seperator}. ".format(
# seperator=CodePatcher.separator.replace("\n", "\\n") seperator=CodePatcher.separator.replace("\n", "\\n")
# ) )
# + "Each patch has to be formatted like below.\n" + "Each patch has to be formatted like below.\n"
# "<filepath>|<start_line>,<start_col>|<end_line>,<end_col>|<new_code>" "<filepath>|<start_line>,<start_col>|<end_line>,<end_col>|<new_code>"
# "Here is an example. If the original code is:\n" "Here is an example. If the original code is:\n"
# "print('hello world')\n" "print('hello world')\n"
# "and you want to change it to:\n" "and you want to change it to:\n"
# "print('hi corca')\n" "print('hi corca')\n"
# "then the patch should be:\n" "then the patch should be:\n"
# "test.py|1,8|1,19|hi corca\n" "test.py|1,8|1,19|hi corca\n"
# "Code between start and end will be replaced with new_code. " "Code between start and end will be replaced with new_code. "
# "The output will be written/deleted bytes or error message. ", "The output will be written/deleted bytes or error message. ",
# ) )
def patch(self, patches: str) -> str: def patch(self, patches: str) -> str:
try: try:
w, d = CodePatcher.patch(patches) w, d = CodePatcher.patch(patches)
@ -831,7 +831,4 @@ class CodeEditor(BaseToolSet):
f"Output Answer: {output}" f"Output Answer: {output}"
) )
return output return output
###################### EDITOR// INIT.PY END

@ -17,8 +17,8 @@ file_management_tools = FileManagementToolkit(
).get_tools() ).get_tools()
read_tool, write_tool, list_tool = file_management_tools read_tool, write_tool, list_tool = file_management_tools
write_tool.run({"file_path": "example.txt", "text": "Hello World!"}) # write_tool.run({"file_path": "example.txt", "text": "Hello World!"})
# List files in the working directory # # List files in the working directory
list_tool.run({}) # list_tool.run({})

Loading…
Cancel
Save