@ -3,38 +3,20 @@ from pydantic import ValidationError
# ---------- Boss Node ----------
# ---------- Boss Node ----------
class BossNode :
class BossNode :
def __init__ ( self , llm , vectorstore , task _executi on_chain, ve rbose , max_iterations ) :
def __init__ ( self , llm , vectorstore , agen t_executor, max_iterations ) :
self . llm = llm
self . llm = llm
self . vectorstore = vectorstore
self . vectorstore = vectorstore
self . task_execution_chain = task_execution_chain
self . agent_executor = agent_executor
self . verbose = verbose
self . max_iterations = max_iterations
self . max_iterations = max_iterations
try :
try :
# Ensure llm is a dictionary before passing it to BabyAGI
assert isinstance ( llm , dict ) , " llm should be a dictionary. "
self . baby_agi = BabyAGI . from_llm (
self . baby_agi = BabyAGI . from_llm (
llm = self . llm ,
llm = self . llm ,
vectorstore = self . vectorstore ,
vectorstore = self . vectorstore ,
task_execution_chain = self . task_execution_chain ,
task_execution_chain = self . agent_executor ,
verbose = self . verbose ,
max_iterations = self . max_iterations ,
max_iterations = self . max_iterations ,
)
)
except ValidationError as e :
except ValidationError as e :
print ( f " Validation Error while initializing BabyAGI: { e } " )
print ( f " Validation Error while initializing BabyAGI: { e } " )
except Exception as e :
except Exception as e :
print ( f " Unexpected Error while initializing BabyAGI: { e } " )
print ( f " Unexpected Error while initializing BabyAGI: { e } " )
def create_task ( self , objective ) :
try :
task = { " objective " : objective }
return task
except Exception as e :
print ( f " Unexpected Error while creating a task: { e } " )
def execute_task ( self , task ) :
try :
self . baby_agi ( task )
except Exception as e :
print ( f " Unexpected Error while executing a task: { e } " )