From e456b9a5c61a9b211ad6d421360328c989e5d343 Mon Sep 17 00:00:00 2001 From: Kye Date: Fri, 6 Oct 2023 00:36:37 -0400 Subject: [PATCH] worker clean up Former-commit-id: 2144e962eb033e9cc65560b4fabfd7ffbd1dced8 --- example.py | 10 ++++++++-- omnimodal_agent_example.py | 2 ++ chat.py => playground/chat.py | 0 .../mm_agent_example.py | 0 .../omni_exa_example.py | 0 swarms/swarms/groupchat.py | 19 ++++++++++++++++++- swarms/workers/worker.py | 5 +++-- 7 files changed, 31 insertions(+), 5 deletions(-) rename chat.py => playground/chat.py (100%) rename mm_agent_example.py => playground/mm_agent_example.py (100%) rename omni_exa_example.py => playground/omni_exa_example.py (100%) diff --git a/example.py b/example.py index 7b708fec..d1e6fc05 100644 --- a/example.py +++ b/example.py @@ -1,9 +1,15 @@ +from langchain.models import OpenAIChat from swarms import Worker +llm = OpenAIChat() + node = Worker( - openai_api_key="", + llm=llm, ai_name="Optimus Prime", - + ai_role="Worker in a swarm", + external_tools = None, + human_in_the_loop = False, + temperature = 0.5, ) task = "What were the winning boston marathon times for the past 5 years (ending in 2022)? Generate a table of the year, name, country of origin, and times." diff --git a/omnimodal_agent_example.py b/omnimodal_agent_example.py index bb921fc3..904d9e9e 100644 --- a/omnimodal_agent_example.py +++ b/omnimodal_agent_example.py @@ -3,5 +3,7 @@ from swarms.agents import OmniModalAgent llm = OpenAIChat(model_name="gpt-4") + agent = OmniModalAgent(llm) + agent.run("Create a video of a swarm of fish") \ No newline at end of file diff --git a/chat.py b/playground/chat.py similarity index 100% rename from chat.py rename to playground/chat.py diff --git a/mm_agent_example.py b/playground/mm_agent_example.py similarity index 100% rename from mm_agent_example.py rename to playground/mm_agent_example.py diff --git a/omni_exa_example.py b/playground/omni_exa_example.py similarity index 100% rename from omni_exa_example.py rename to playground/omni_exa_example.py diff --git a/swarms/swarms/groupchat.py b/swarms/swarms/groupchat.py index 9b5e9552..d2874763 100644 --- a/swarms/swarms/groupchat.py +++ b/swarms/swarms/groupchat.py @@ -155,4 +155,21 @@ class GroupChatManager(Worker): ) message = self.last_message(speaker) message = self.last_messge(speaker) - return True, None \ No newline at end of file + return True, None + +model = GroupChatManager( + groupchat=GroupChat( + workers=[ + Worker(name="A", system_message="I am worker A"), + Worker(name="B", system_message="I am worker B"), + Worker(name="C", system_message="I am worker C"), + ] + ) +) + +model.run( + messages=[ + 'A: Hello, I am worker A', + 'B: Hello, I am worker B', + ] +) \ No newline at end of file diff --git a/swarms/workers/worker.py b/swarms/workers/worker.py index 5753aeef..fd97e5de 100644 --- a/swarms/workers/worker.py +++ b/swarms/workers/worker.py @@ -58,10 +58,12 @@ class Worker: print(response) ``` + llm + tools + memory + """ def __init__( self, - openai_api_key: str = None, + ai_name: str = "Autobot Swarm Worker", ai_role: str = "Worker in a swarm", external_tools = None, @@ -69,7 +71,6 @@ class Worker: temperature: float = 0.5, llm = None, ): - self.openai_api_key = openai_api_key self.temperature = temperature self.human_in_the_loop = human_in_the_loop self.llm = llm