clean up external tools

Former-commit-id: 0ec4f1a5b7
group-chat
Kye 1 year ago
parent a6f31a88f2
commit 7510ce9e01

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

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

Loading…
Cancel
Save