"""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"""
"""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):
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):
defadd_tool(self,tool:Tool):
ifnotisinstance(tool,Tool):
raiseTypeError("Tool must be an instance of Tool")
self.tools.append(tool)
self.tools.append(tool)
defrun(self,prompt:str)->str:
defrun(self,prompt:str)->str:
@ -45,25 +55,39 @@ class WorkerNode:
ifnotprompt:
ifnotprompt:
raiseValueError("Prompt is empty")
raiseValueError("Prompt is empty")
try:
self.agent.run([f"{prompt}"])
self.agent.run([f"{prompt}"])
return"Task completed by WorkerNode"
return"Task completed by WorkerNode"
exceptExceptionase:
logging.error(f"While running the agent: {str(e)}")
raisee
worker_tool=Tool(
name="WorkerNode AI Agent",
# worker_tool = Tool(
func=WorkerNode.run,
# name="WorkerNode AI Agent",
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"
# 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"