diff --git a/swarms/__init__.py b/swarms/__init__.py index 976c06c8..82b09f9e 100644 --- a/swarms/__init__.py +++ b/swarms/__init__.py @@ -3,7 +3,7 @@ from swarms.orchestrator.autoscaler import AutoScaler # worker # from swarms.workers.worker_node import WorkerNode -from swarms.workers.workers import Workers +from swarms.workers.worker import Worker from swarms.workers.autobot import AutoBot #boss diff --git a/swarms/orchestrator/autoscaler.py b/swarms/orchestrator/autoscaler.py index e78b5d4f..181651ca 100644 --- a/swarms/orchestrator/autoscaler.py +++ b/swarms/orchestrator/autoscaler.py @@ -18,9 +18,11 @@ class AutoScaler: initial_agents=10, scale_up_factor=1, idle_threshold=0.2, - busy_threshold=0.7 + busy_threshold=0.7, + agent=None, ): - self.agents_pool = [AutoBot() for _ in range(initial_agents)] + self.agent = agent or AutoBot + self.agents_pool = [self.agent() for _ in range(initial_agents)] self.task_queue = queue.Queue() self.scale_up_factor = scale_up_factor self.idle_threshold = idle_threshold @@ -71,3 +73,9 @@ class AutoScaler: if available_agent: available_agent.run(task) +#usage of usage +#auto_scaler = AutoScaler(agent=YourCustomAgent) +# auto_scaler.start() + +#for i in range(100): +# auto_scaler.add_task9f"task {I}}) \ No newline at end of file diff --git a/swarms/workers/workers.py b/swarms/workers/worker.py similarity index 92% rename from swarms/workers/workers.py rename to swarms/workers/worker.py index b3df84bd..6c45d0c1 100644 --- a/swarms/workers/workers.py +++ b/swarms/workers/worker.py @@ -4,6 +4,8 @@ from langchain.docstore import InMemoryDocstore from langchain.embeddings import OpenAIEmbeddings from langchain.vectorstores import FAISS from langchain_experimental.autonomous_agents import AutoGPT +from langchain.tools.human.tool import HumanInputRun + from swarms.agents.tools.autogpt import ( ReadFileTool, @@ -17,7 +19,7 @@ from swarms.utils.decorators import error_decorator, log_decorator, timing_decor ROOT_DIR = "./data/" -class Workers: +class Worker: @log_decorator @error_decorator @timing_decorator @@ -28,9 +30,12 @@ class Workers: ai_role="Worker in a swarm", # embedding_size=None, # k=None, + human_in_the_loop=False, temperature=0.5): self.openai_api_key = openai_api_key self.temperature = temperature + self.human_in_the_loop = human_in_the_loop + try: self.llm = ChatOpenAI(model_name=model_name, @@ -58,6 +63,7 @@ class Workers: ReadFileTool(root_dir=ROOT_DIR), process_csv, query_website_tool, + HumanInputRun() ] def setup_memory(self): @@ -78,6 +84,7 @@ class Workers: tools=self.tools, llm=self.llm, memory=self.vectorstore.as_retriever(search_kwargs={"k": 8}), + human_in_the_loop=self.human_in_the_loop ) except Exception as error: