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,
backtracking_threshold=0.4,
initial_prompt=None,
openai_api_key: str = None
openai_api_key: str = None,
model = None,
):
self.num_thoughts = num_thoughts
self.max_steps = max_steps
@ -213,7 +214,8 @@ class AoTAgent:
self.initial_prompt = initial_prompt
self.output = []
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):
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 queue
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
@ -20,7 +20,7 @@ class AutoScaler:
busy_threshold=0.7,
agent=None,
):
self.agent = agent or AutoBot
self.agent = agent or Worker
self.agents_pool = [self.agent() for _ in range(initial_agents)]
self.task_queue = queue.Queue()
self.scale_up_factor = scale_up_factor
@ -37,7 +37,7 @@ class AutoScaler:
with self.lock:
new_agents_counts = len(self.agents_pool) * self.scale_up_factor
for _ in range(new_agents_counts):
self.agents_pool.append(AutoBot())
self.agents_pool.append(Worker())
def scale_down(self):
with self.lock:

@ -1,14 +1,44 @@
from abc import ABC
from shapeless import shapeless
@shapeless
class Task:
class BaseTask(ABC):
def __init__(
self,
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
def reset(self):
pass

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

Loading…
Cancel
Save