Former-commit-id: ffcce48cbad94f580417d03ec3bd75b5cb0c05c7
pull/160/head
Kye 2 years ago
parent e2d3188ba8
commit 241b99ec27

@ -6,7 +6,7 @@ from swarms.tools.agent_tools import *
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
# ---------- Boss Node ---------- # ---------- Boss Node ----------
class BossNode: class BossNodeInitializer:
""" """
The BossNode class is responsible for creating and executing tasks using the BabyAGI model. The BossNode class is responsible for creating and executing tasks using the BabyAGI model.
It takes a language model (llm), a vectorstore for memory, an agent_executor for task execution, and a maximum number of iterations for the BabyAGI model. It takes a language model (llm), a vectorstore for memory, an agent_executor for task execution, and a maximum number of iterations for the BabyAGI model.
@ -72,7 +72,7 @@ class BossNode:
raise ValueError("Objective cannot be empty.") raise ValueError("Objective cannot be empty.")
return {"objective": objective} return {"objective": objective}
def execute_task(self, task): def run(self, task):
""" """
Executes a task using the BabyAGI model. Executes a task using the BabyAGI model.
""" """
@ -89,7 +89,7 @@ class BossNode:
# from swarms import BossNode, OpenAI, LLMChain, Tool, ZeroShotAgent, AgentExecutor, PromptTemplate # from swarms import BossNode, OpenAI, LLMChain, Tool, ZeroShotAgent, AgentExecutor, PromptTemplate
def boss_node(objective, api_key=None, vectorstore=None, worker_node=None, llm_class=OpenAI, max_iterations=5, verbose=False): def BossNode(objective, api_key=None, vectorstore=None, worker_node=None, llm_class=OpenAI, max_iterations=5, verbose=False):
""" """
Wrapper function to initialize and use BossNode with given parameters. Wrapper function to initialize and use BossNode with given parameters.
API key can be passed as argument or set as an environment variable. API key can be passed as argument or set as an environment variable.

@ -3,7 +3,7 @@ import asyncio
from swarms.tools.agent_tools import * from swarms.tools.agent_tools import *
from swarms.agents.workers.WorkerNode import WorkerNode, worker_node from swarms.agents.workers.WorkerNode import WorkerNode, worker_node
from swarms.agents.boss.BossNode import BossNode from swarms.agents.boss.BossNode import BossNodeInitializer as BossNode
from swarms.agents.workers.WorkerUltraNode import WorkerUltra from swarms.agents.workers.WorkerUltraNode import WorkerUltra
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
@ -159,7 +159,7 @@ class Swarms:
task = boss_node.create_task(objective) task = boss_node.create_task(objective)
logging.info(f"Running task: {task}") logging.info(f"Running task: {task}")
result = await boss_node.execute_task(task) result = await boss_node.run(task)
logging.info(f"Completed tasks: {task}") logging.info(f"Completed tasks: {task}")
return result return result
except Exception as e: except Exception as e:

Loading…
Cancel
Save