pull/55/head
Kye 1 year ago
parent 9ff3dfa3d9
commit fd01d22e87

@ -0,0 +1,6 @@
from swarms.workflows.main import Workflow
workflow = Workflow()
workflow.add('Find 50 ceos in linkedin in agriculture ')

@ -203,7 +203,8 @@ class AoTAgent:
pruning_threshold=0.5, pruning_threshold=0.5,
backtracking_threshold=0.4, backtracking_threshold=0.4,
initial_prompt=None, initial_prompt=None,
openai_api_key: str = None openai_api_key: str = None,
model = None,
): ):
self.num_thoughts = num_thoughts self.num_thoughts = num_thoughts
self.max_steps = max_steps self.max_steps = max_steps
@ -213,7 +214,8 @@ class AoTAgent:
self.initial_prompt = initial_prompt self.initial_prompt = initial_prompt
self.output = [] self.output = []
self.openai_api_key = openai_api_key self.openai_api_key = openai_api_key
self.model = OpenAI(api_key=self.openai_api_key) self.model = model
self.model = self.model or OpenAI(api_key=self.openai_api_key)
def solve(self): def solve(self):
try: try:

@ -0,0 +1,16 @@
from shapeless import shapeless
@shapeless
class ErrorArtifact:
def __init__(
self,
value
):
self.value = value
def __add__(self, other):
return ErrorArtififact(self.value + other.value)
def to_text(self) -> str:
return self.value

@ -1,7 +1,7 @@
import threading import threading
import queue import queue
from time import sleep from time import sleep
from swarms.workers.autobot import AutoBot from swarms.workers.worker import Worker
from swarms.utils.decorators import error_decorator, log_decorator, timing_decorator from swarms.utils.decorators import error_decorator, log_decorator, timing_decorator
@ -20,7 +20,7 @@ class AutoScaler:
busy_threshold=0.7, busy_threshold=0.7,
agent=None, agent=None,
): ):
self.agent = agent or AutoBot self.agent = agent or Worker
self.agents_pool = [self.agent() for _ in range(initial_agents)] self.agents_pool = [self.agent() for _ in range(initial_agents)]
self.task_queue = queue.Queue() self.task_queue = queue.Queue()
self.scale_up_factor = scale_up_factor self.scale_up_factor = scale_up_factor
@ -37,7 +37,7 @@ class AutoScaler:
with self.lock: with self.lock:
new_agents_counts = len(self.agents_pool) * self.scale_up_factor new_agents_counts = len(self.agents_pool) * self.scale_up_factor
for _ in range(new_agents_counts): for _ in range(new_agents_counts):
self.agents_pool.append(AutoBot()) self.agents_pool.append(Worker())
def scale_down(self): def scale_down(self):
with self.lock: with self.lock:

@ -1,14 +1,44 @@
from abc import ABC
from shapeless import shapeless from shapeless import shapeless
@shapeless @shapeless
class Task: class BaseTask(ABC):
def __init__( def __init__(
self, self,
id, id,
): ):
self.id = id self.id = id
def forward(self): def add(self):
pass
def schedule(self, time):
pass
def parents(self):
pass
def children(self):
pass
def preprocess(self):
pass
def add_parent(self):
pass
def is_pending(self):
pass
def is_finished(self):
pass
def is_executing(self):
pass
def run(self):
pass pass
def reset(self):
pass

@ -1,13 +1,21 @@
from __future__ import annotations from __future__ import annotations
import concurrent.futures as futures
import logging import logging
import uuid import uuid
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from graphlib import TopologicalSorter
from logging import Logger from logging import Logger
from typing import Optional, Union, TYPE_CHECKING, Callable, Type from typing import Optional, Union
from rich.logging import RichHandler from rich.logging import RichHandler
import concurrent.futures as futures from shapeless import shapeless
from graphlib import TopologicalSorter
from swarms.artifacts.error_artifact import ErrorArtifact
from swarms.structs.task import BaseTask
@shapeless
class Workflow(ABC): class Workflow(ABC):
def __init__( def __init__(
self, self,
@ -72,7 +80,7 @@ class Workflow(ABC):
} }
@abstractmethod @abstractmethod
def add_task(self, task: BaseTask) -> BaseTask: def add(self, task: BaseTask) -> BaseTask:
task.preprocess(self) task.preprocess(self)
self.tasks.append(task) self.tasks.append(task)
return task return task

Loading…
Cancel
Save