main
Kye 2 years ago
parent 80750a32bd
commit 0e70d1edc8

@ -8,14 +8,12 @@ from langchain.callbacks.manager import (
class WorkerNode(BaseTool):
"""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 """
name = "WorkerNode"
description = "A worker node that can perform complex tasks"
llm: Any = Field(description="Language model")
tools: List[Tool] = Field(description="List of tools")
vectorstore: VectorStore = Field(description="Vector store")
def __init__(self, **data):
super().__init__(**data)
def __init__(self, llm, tools, vectorstore):
super().__init__()
self.llm = llm
self.tools = tools
self.vectorstore = vectorstore
def create_agent(self, ai_name, ai_role, human_in_the_loop, search_kwargs):
self.agent = AutoGPT.from_llm_and_tools(

@ -65,10 +65,13 @@ class Swarms:
llm = self.initialize_llm()
tools = self.initialize_tools(llm)
vectorstore = self.initialize_vectorstore()
worker_node = self.initialize_worker_node(llm, tools, vectorstore) # Corrected here
worker_node = self.initialize_worker_node(llm, tools, vectorstore)
boss_node = self.initialize_boss_node(llm, vectorstore)
task = boss_node.create_task(objective)
boss_node.execute_task(task)
worker_node.run_agent(objective)
# class Swarms:
# def __init__(self, num_nodes: int, llm: BaseLLM, self_scaling: bool):
# self.nodes = [WorkerNode(llm) for _ in range(num_nodes)]

Loading…
Cancel
Save