From 0ec4f1a5b7a9a7619687f06763dc627680007534 Mon Sep 17 00:00:00 2001 From: Kye Date: Fri, 25 Aug 2023 14:27:22 -0400 Subject: [PATCH] clean up external tools --- example.py | 1 + swarms/workers/worker.py | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/example.py b/example.py index 8a5a8a18..b16c59e6 100644 --- a/example.py +++ b/example.py @@ -4,6 +4,7 @@ from swarms import Worker node = Worker( openai_api_key="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", ai_name="Optimus Prime", + ) task = "What were the winning boston marathon times for the past 5 years (ending in 2022)? Generate a table of the year, name, country of origin, and times." diff --git a/swarms/workers/worker.py b/swarms/workers/worker.py index 6c45d0c1..f4f829c5 100644 --- a/swarms/workers/worker.py +++ b/swarms/workers/worker.py @@ -28,8 +28,7 @@ class Worker: openai_api_key=None, ai_name="Autobot Swarm Worker", ai_role="Worker in a swarm", - # embedding_size=None, - # k=None, + external_tools = None, human_in_the_loop=False, temperature=0.5): self.openai_api_key = openai_api_key @@ -50,14 +49,25 @@ class Worker: # self.embedding_size = embedding_size # # self.k = k - self.setup_tools() + self.setup_tools(external_tools) self.setup_memory() self.setup_agent() @log_decorator @error_decorator @timing_decorator - def setup_tools(self): + def setup_tools(self, external_tools): + """ + external_tools = [MyTool1(), MyTool2()] + worker = Worker(model_name="gpt-4", + openai_api_key="my_key", + ai_name="My Worker", + ai_role="Worker", + external_tools=external_tools, + human_in_the_loop=False, + temperature=0.5) + + """ self.tools = [ WriteFileTool(root_dir=ROOT_DIR), ReadFileTool(root_dir=ROOT_DIR), @@ -65,6 +75,8 @@ class Worker: query_website_tool, HumanInputRun() ] + if external_tools is not None: + self.tools.extend(external_tools) def setup_memory(self): try: