main
Kye 2 years ago
parent ca3fdb03bb
commit 566b85e34b

@ -0,0 +1,22 @@
# ---------- Boss Node ----------
class BossNode:
def __init__(self, llm, vectorstore, task_execution_chain, verbose, max_iterations):
self.llm = llm
self.vectorstore = vectorstore
self.task_execution_chain = task_execution_chain
self.verbose = verbose
self.max_iterations = max_iterations
self.baby_agi = BabyAGI.from_llm(
llm=self.llm,
vectorstore=self.vectorstore,
task_execution_chain=self.task_execution_chain
)
def create_task(self, objective):
return {"objective": objective}
def execute_task(self, task):
self.baby_agi(task)

@ -32,8 +32,8 @@ from langchain.embeddings import OpenAIEmbeddings
from langchain.tools.human.tool import HumanInputRun
# from swarms.agents.workers.auto_agent import
from swarms.agents.workers.multi_modal import MultiModalVisualAgent
from swarms.tools.main import Terminal, CodeWriter, CodeEditor, process_csv, WebpageQATool
from agents.workers.multi_modal import MultiModalVisualAgent
from tools.main import Terminal, CodeWriter, CodeEditor, process_csv, WebpageQATool
class MultiModalVisualAgentTool(BaseTool):
name = "multi_visual_agent"

@ -0,0 +1,33 @@
# ---------- Worker Node ----------
# Define the input schema for the WorkerNode
class WorkerNodeInput(BaseModel):
llm: Any = Field(description="Language model")
tools: List[Tool] = Field(description="List of tools")
vectorstore: VectorStore = Field(description="Vector store")
@tool("WorkerNode", args_schema=WorkerNodeInput)
class WorkerNode:
"""Useful for when you need to spawn an autonomous agent instance as a worker to accomplish complex tasks, it can search the internet or spawn child multi-modality models to process and generate images and text or audio and so on """
def __init__(self, llm, tools, vectorstore):
self.llm = llm
self.tools = tools
self.vectorstore = vectorstore
def create_agent(self, ai_name, ai_role, human_in_the_loop, search_kwargs):
self.agent = AutoGPT.from_llm_and_tools(
ai_name=ai_name,
ai_role=ai_role,
tools=tools,
llm=self.llm,
memory=self.vectorstore.as_retriever(search_kwargs=search_kwargs),
human_in_the_loop=human_in_the_loop,
)
self.agent.chain.verbose = True
def run_agent(self, prompt):
tree_of_thoughts_prompt = """
Imagine three different experts are answering this question. All experts will write down each chain of thought of each step of their thinking, then share it with the group. Then all experts will go on to the next step, etc. If any expert realises they're wrong at any point then they leave. The question is...
"""
self.agent.run([f"{tree_of_thoughts_prompt} {prompt}"])

@ -1,112 +0,0 @@
class Code:
def __init__(self, value: int):
self.value = value
def __str__(self):
return "%d" % self.value
class Color(Code):
def bg(self) -> "Color":
self.value += 10
return self
def bright(self) -> "Color":
self.value += 60
return self
@staticmethod
def black() -> "Color":
return Color(30)
@staticmethod
def red() -> "Color":
return Color(31)
@staticmethod
def green() -> "Color":
return Color(32)
@staticmethod
def yellow() -> "Color":
return Color(33)
@staticmethod
def blue() -> "Color":
return Color(34)
@staticmethod
def magenta() -> "Color":
return Color(35)
@staticmethod
def cyan() -> "Color":
return Color(36)
@staticmethod
def white() -> "Color":
return Color(37)
@staticmethod
def default() -> "Color":
return Color(39)
class Style(Code):
@staticmethod
def reset() -> "Style":
return Style(0)
@staticmethod
def bold() -> "Style":
return Style(1)
@staticmethod
def dim() -> "Style":
return Style(2)
@staticmethod
def italic() -> "Style":
return Style(3)
@staticmethod
def underline() -> "Style":
return Style(4)
@staticmethod
def blink() -> "Style":
return Style(5)
@staticmethod
def reverse() -> "Style":
return Style(7)
@staticmethod
def conceal() -> "Style":
return Style(8)
class ANSI:
ESCAPE = "\x1b["
CLOSE = "m"
def __init__(self, text: str):
self.text = text
self.args = []
def join(self) -> str:
return ANSI.ESCAPE + ";".join([str(a) for a in self.args]) + ANSI.CLOSE
def wrap(self, text: str) -> str:
return self.join() + text + ANSI(Style.reset()).join()
def to(self, *args: str):
self.args = list(args)
return self.wrap(self.text)
def dim_multiline(message: str) -> str:
lines = message.split("\n")
if len(lines) <= 1:
return lines[0]
return lines[0] + ANSI("\n... ".join([""] + lines[1:])).to(Color.black().bright())
Loading…
Cancel
Save