clean up external tools

pull/53/head
Kye 1 year ago
parent 0efe77183a
commit 0ec4f1a5b7

@ -4,6 +4,7 @@ from swarms import Worker
node = Worker( node = Worker(
openai_api_key="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", openai_api_key="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",
ai_name="Optimus Prime", 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." 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."

@ -28,8 +28,7 @@ class Worker:
openai_api_key=None, openai_api_key=None,
ai_name="Autobot Swarm Worker", ai_name="Autobot Swarm Worker",
ai_role="Worker in a swarm", ai_role="Worker in a swarm",
# embedding_size=None, external_tools = None,
# k=None,
human_in_the_loop=False, human_in_the_loop=False,
temperature=0.5): temperature=0.5):
self.openai_api_key = openai_api_key self.openai_api_key = openai_api_key
@ -50,14 +49,25 @@ class Worker:
# self.embedding_size = embedding_size # self.embedding_size = embedding_size
# # self.k = k # # self.k = k
self.setup_tools() self.setup_tools(external_tools)
self.setup_memory() self.setup_memory()
self.setup_agent() self.setup_agent()
@log_decorator @log_decorator
@error_decorator @error_decorator
@timing_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 = [ self.tools = [
WriteFileTool(root_dir=ROOT_DIR), WriteFileTool(root_dir=ROOT_DIR),
ReadFileTool(root_dir=ROOT_DIR), ReadFileTool(root_dir=ROOT_DIR),
@ -65,6 +75,8 @@ class Worker:
query_website_tool, query_website_tool,
HumanInputRun() HumanInputRun()
] ]
if external_tools is not None:
self.tools.extend(external_tools)
def setup_memory(self): def setup_memory(self):
try: try:

Loading…
Cancel
Save