"""Useful for when you need to spawn an autonomous agent instance as a worker to accomplish complex tasks, it can search the internet or spawn child multi-modality models to process and generate images and text or audio and so on"""
def__init__(self,llm,tools,vectorstore):
ifnotllmornottoolsornotvectorstore:
raiseValueError("llm, tools, and vectorstore cannot be None")
logging.error(f"Error while creating agent: {str(e)}")
raisee
defadd_tool(self,tool:Tool):
ifnotisinstance(tool,Tool):
raiseTypeError("Tool must be an instance of Tool")
self.tools.append(tool)
defrun(self,prompt:str)->str:
@ -44,26 +54,40 @@ class WorkerNode:
ifnotprompt:
raiseValueError("Prompt is empty")
self.agent.run([f"{prompt}"])
return"Task completed by WorkerNode"
try:
self.agent.run([f"{prompt}"])
return"Task completed by WorkerNode"
exceptExceptionase:
logging.error(f"While running the agent: {str(e)}")
raisee
worker_tool=Tool(
name="WorkerNode AI Agent",
func=WorkerNode.run,
description="Useful for when you need to spawn an autonomous agent instance as a worker to accomplish complex tasks, it can search the internet or spawn child multi-modality models to process and generate images and text or audio and so on"
)
# worker_tool = Tool(
# name="WorkerNode AI Agent",
# func=WorkerNode.run,
# description="Useful for when you need to spawn an autonomous agent instance as a worker to accomplish complex tasks, it can search the internet or spawn child multi-modality models to process and generate images and text or audio and so on"