Open Veanir opened 1 month ago
Hello there, thank you for opening an Issue ! 🙏🏻 The team was notified and they will get back to you asap.
@Veanir hey excuse, me think i just fixed it, try upgrading and then let me know: pip3 install -U swarms
I set up a colab notebook replicator with the latest swarms. It ran, but ran out of memory after only producing
32m2024-06-17T23:14:10.620655+0000[0m [1mReliability checks activated.[0m
If interrupted before running out of memory I get;
KeyboardInterrupt Traceback (most recent call last)
[<ipython-input-2-1f396324b767>](https://localhost:8080/#) in <cell line: 27>()
25
26 # Load the swarmnet with the agents
---> 27 swarmnet = SwarmNetwork(
28 agents=[agent, agent2, agent3],
29 )
[/usr/local/lib/python3.10/dist-packages/swarms/structs/swarm_net.py](https://localhost:8080/#) in __init__(self, name, description, agents, idle_threshold, busy_threshold, api_enabled, logging_enabled, api_on, host, port, swarm_callable, *args, **kwargs)
145 if agents is not None:
146 for agent in agents:
--> 147 self.agents.append(agent)
148
149 # Create the FastAPI instance
KeyboardInterrupt:
I'll dig in a bit more.
Yea, seems like infinite loop to me
# For each agent in the pool, run it on it's own thread
if agents is not None:
for agent in agents:
self.agents.append(agent)
Ok, I think I figured this out. This code is recursively adding agents to agents, and so will never stop, and will oom. swarms/structs/swarm_net.py 144 You likely don't need this code at all. The agents have already been added with self.agents.
# For each agent in the pool, run it on it's own thread
if agents is not None:
for agent in agents:
self.agents.append(agent)
@Veanir @evelynmitchell i've tried fixing it, thanks good catch. try upgrading now!
Describe the bug BaseSwarm class throws value error when instantiating SwarmNetwork when using provided Swarm Network example.
To Reproduce Steps to reproduce the behavior:
from dotenv import load_dotenv
Import the OpenAIChat model and the Agent struct
from swarms import Agent, OpenAIChat, SwarmNetwork
Load the environment variables
load_dotenv()
Get the API key from the environment
api_key = os.environ.get("OPENAI_API_KEY")
Initialize the language model
llm = OpenAIChat( temperature=0.5, openai_api_key=api_key, )
Initialize the workflow
agent = Agent(llm=llm, max_loops=1, agent_name="Social Media Manager") agent2 = Agent(llm=llm, max_loops=1, agent_name=" Product Manager") agent3 = Agent(llm=llm, max_loops=1, agent_name="SEO Manager")
Load the swarmnet with the agents
swarmnet = SwarmNetwork( agents=[agent, agent2, agent3], )
List the agents in the swarm network
out = swarmnet.list_agents() print(out)
Run the workflow on a task
out = swarmnet.run_single_agent( agent2.id, "Generate a 10,000 word blog on health and wellness." ) print(out)
Run all the agents in the swarm network on a task
out = swarmnet.run_many_agents("Generate a 10,000 word blog on health and wellness.") print(out)