human input run

Former-commit-id: be161a9a7a
group-chat
Kye 1 year ago
parent 73b2f0ea62
commit 1a1b44552a

@ -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

@ -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}})

@ -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:
Loading…
Cancel
Save