pull/59/head
Kye 1 year ago
parent 6aa7b00bb8
commit 0ab9725fe7

@ -47,11 +47,13 @@ class Workflow:
return response
def __init__(self, agent, parallel: bool = False):
"""__init__"""
self.agent = agent
self.tasks: List[Workflow.Task] = []
self.parallel = parallel
def add(self, task: str) -> Task:
"""Add a task"""
task = self.Task(task)
if self.last_task():
@ -62,12 +64,15 @@ class Workflow:
return task
def first_task(self) -> Optional[Task]:
"""Add first task"""
return self.tasks[0] if self.tasks else None
def last_task(self) -> Optional[Task]:
"""Last task"""
return self.tasks[-1] if self.tasks else None
def run(self, *args) -> Task:
"""Run tasks"""
[task.reset() for task in self.tasks]
if self.parallel:
@ -79,6 +84,7 @@ class Workflow:
return self.last_task()
def context(self, task: Task) -> Dict[str, Any]:
"""Context in tasks"""
return {
"parent_output": task.parents[0].output
if task.parents and task.parents[0].output
@ -88,6 +94,7 @@ class Workflow:
}
def __run_from_task(self, task: Optional[Task]) -> None:
"""Run from task"""
if task is None:
return
else:

@ -1,29 +1,30 @@
import interpreter
from transformers import (
BlipForQuestionAnswering,
BlipProcessor,
)
from PIL import Image
import torch
from swarms.utils.logger import logger
from pydantic import Field
from langchain.tools.file_management.write import WriteFileTool
from langchain.tools.file_management.read import ReadFileTool
from langchain.tools import BaseTool
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.chains.qa_with_sources.loading import BaseCombineDocumentsChain
import asyncio
import os
# Tools
from contextlib import contextmanager
from typing import Optional
import interpreter
import pandas as pd
import torch
from langchain.agents import tool
from langchain.agents.agent_toolkits.pandas.base import create_pandas_dataframe_agent
from langchain.chains.qa_with_sources.loading import load_qa_with_sources_chain
from langchain.chains.qa_with_sources.loading import (
BaseCombineDocumentsChain,
load_qa_with_sources_chain,
)
from langchain.docstore.document import Document
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.tools import BaseTool
from langchain.tools.file_management.read import ReadFileTool
from langchain.tools.file_management.write import WriteFileTool
from PIL import Image
from pydantic import Field
from transformers import (
BlipForQuestionAnswering,
BlipProcessor,
)
from swarms.utils.logger import logger
ROOT_DIR = "./data/"

@ -1,18 +1,20 @@
from typing import Dict, List, Optional, Union
import faiss
from langchain.docstore import InMemoryDocstore
from langchain.embeddings import OpenAIEmbeddings
from langchain.tools.human.tool import HumanInputRun
from langchain.vectorstores import FAISS
from langchain_experimental.autonomous_agents import AutoGPT
from typing import Dict, List, Optional, Union
from swarms.agents.message import Message
from swarms.tools.autogpt import (
ReadFileTool,
WebpageQATool,
WriteFileTool,
compile,
process_csv,
load_qa_with_sources_chain,
WebpageQATool,
process_csv,
)
from swarms.utils.decorators import error_decorator, log_decorator, timing_decorator

Loading…
Cancel
Save