swarms 7.8.3__py3-none-any.whl → 7.8.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- swarms/agents/ape_agent.py +5 -22
- swarms/agents/consistency_agent.py +1 -1
- swarms/agents/i_agent.py +1 -1
- swarms/agents/reasoning_agents.py +99 -3
- swarms/agents/reasoning_duo.py +1 -1
- swarms/cli/main.py +1 -1
- swarms/communication/__init__.py +1 -0
- swarms/communication/duckdb_wrap.py +32 -2
- swarms/communication/pulsar_struct.py +45 -19
- swarms/communication/redis_wrap.py +56 -11
- swarms/communication/supabase_wrap.py +1659 -0
- swarms/prompts/agent_conversation_aggregator.py +38 -0
- swarms/prompts/prompt.py +0 -3
- swarms/schemas/agent_completion_response.py +71 -0
- swarms/schemas/agent_rag_schema.py +7 -0
- swarms/schemas/conversation_schema.py +9 -0
- swarms/schemas/llm_agent_schema.py +99 -81
- swarms/schemas/swarms_api_schemas.py +164 -0
- swarms/structs/__init__.py +15 -9
- swarms/structs/agent.py +219 -199
- swarms/structs/agent_rag_handler.py +685 -0
- swarms/structs/base_swarm.py +2 -1
- swarms/structs/conversation.py +832 -264
- swarms/structs/csv_to_agent.py +153 -100
- swarms/structs/deep_research_swarm.py +197 -193
- swarms/structs/dynamic_conversational_swarm.py +18 -7
- swarms/structs/hiearchical_swarm.py +1 -1
- swarms/structs/hybrid_hiearchical_peer_swarm.py +2 -18
- swarms/structs/image_batch_processor.py +261 -0
- swarms/structs/interactive_groupchat.py +356 -0
- swarms/structs/ma_blocks.py +159 -0
- swarms/structs/majority_voting.py +1 -1
- swarms/structs/mixture_of_agents.py +1 -1
- swarms/structs/multi_agent_exec.py +25 -26
- swarms/structs/multi_agent_router.py +3 -2
- swarms/structs/rearrange.py +3 -3
- swarms/structs/sequential_workflow.py +3 -3
- swarms/structs/swarm_matcher.py +499 -408
- swarms/structs/swarm_router.py +15 -97
- swarms/structs/swarming_architectures.py +1 -1
- swarms/tools/mcp_client_call.py +3 -0
- swarms/utils/__init__.py +10 -2
- swarms/utils/check_all_model_max_tokens.py +43 -0
- swarms/utils/generate_keys.py +0 -27
- swarms/utils/history_output_formatter.py +5 -20
- swarms/utils/litellm_wrapper.py +208 -60
- swarms/utils/output_types.py +24 -0
- swarms/utils/vllm_wrapper.py +14 -13
- swarms/utils/xml_utils.py +37 -2
- {swarms-7.8.3.dist-info → swarms-7.8.7.dist-info}/METADATA +31 -55
- {swarms-7.8.3.dist-info → swarms-7.8.7.dist-info}/RECORD +55 -48
- swarms/structs/multi_agent_collab.py +0 -242
- swarms/structs/output_types.py +0 -6
- swarms/utils/markdown_message.py +0 -21
- swarms/utils/visualizer.py +0 -510
- swarms/utils/wrapper_clusterop.py +0 -127
- /swarms/{tools → schemas}/tool_schema_base_model.py +0 -0
- {swarms-7.8.3.dist-info → swarms-7.8.7.dist-info}/LICENSE +0 -0
- {swarms-7.8.3.dist-info → swarms-7.8.7.dist-info}/WHEEL +0 -0
- {swarms-7.8.3.dist-info → swarms-7.8.7.dist-info}/entry_points.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: swarms
|
3
|
-
Version: 7.8.
|
3
|
+
Version: 7.8.7
|
4
4
|
Summary: Swarms - TGSC
|
5
5
|
License: MIT
|
6
6
|
Keywords: artificial intelligence,deep learning,optimizers,Prompt Engineering,swarms,agents,llms,transformers,multi-agent,swarms of agents,Enterprise-Grade Agents,Production-Grade Agents,Agents,Multi-Grade-Agents,Swarms,Transformers,LLMs,Prompt Engineering,Agents,Generative Agents,Generative AI,Agent Marketplace,Agent Store,quant,finance,algorithmic trading,portfolio optimization,risk management,financial modeling,machine learning for finance,natural language processing for finance
|
@@ -1424,15 +1424,13 @@ print(out)
|
|
1424
1424
|
-------
|
1425
1425
|
|
1426
1426
|
## SpreadSheetSwarm
|
1427
|
+
|
1427
1428
|
SpreadSheetSwarm manages thousands of agents concurrently for efficient task processing. It supports one-to-many task distribution, scalability, and autosaving results. Initialized with a name, description, agents, and settings, the run method executes tasks and returns a dictionary of agent outputs.
|
1428
1429
|
|
1429
1430
|
[Learn more:](https://docs.swarms.world/en/latest/swarms/structs/spreadsheet_swarm/)
|
1430
1431
|
|
1431
1432
|
```python
|
1432
|
-
import os
|
1433
1433
|
from swarms import Agent, SpreadSheetSwarm
|
1434
|
-
from swarm_models import OpenAIChat
|
1435
|
-
|
1436
1434
|
# Define custom system prompts for each social media platform
|
1437
1435
|
TWITTER_AGENT_SYS_PROMPT = """
|
1438
1436
|
You are a Twitter marketing expert specializing in real estate. Your task is to create engaging, concise tweets to promote properties, analyze trends to maximize engagement, and use appropriate hashtags and timing to reach potential buyers.
|
@@ -1459,7 +1457,7 @@ agents = [
|
|
1459
1457
|
Agent(
|
1460
1458
|
agent_name="Twitter-RealEstate-Agent",
|
1461
1459
|
system_prompt=TWITTER_AGENT_SYS_PROMPT,
|
1462
|
-
model_name="gpt-4o",
|
1460
|
+
model_name="gpt-4o-mini",
|
1463
1461
|
max_loops=1,
|
1464
1462
|
dynamic_temperature_enabled=True,
|
1465
1463
|
saved_state_path="twitter_realestate_agent.json",
|
@@ -1469,7 +1467,7 @@ agents = [
|
|
1469
1467
|
Agent(
|
1470
1468
|
agent_name="Instagram-RealEstate-Agent",
|
1471
1469
|
system_prompt=INSTAGRAM_AGENT_SYS_PROMPT,
|
1472
|
-
model_name="gpt-4o",
|
1470
|
+
model_name="gpt-4o-mini",
|
1473
1471
|
max_loops=1,
|
1474
1472
|
dynamic_temperature_enabled=True,
|
1475
1473
|
saved_state_path="instagram_realestate_agent.json",
|
@@ -1479,7 +1477,7 @@ agents = [
|
|
1479
1477
|
Agent(
|
1480
1478
|
agent_name="Facebook-RealEstate-Agent",
|
1481
1479
|
system_prompt=FACEBOOK_AGENT_SYS_PROMPT,
|
1482
|
-
model_name="gpt-4o",
|
1480
|
+
model_name="gpt-4o-mini",
|
1483
1481
|
max_loops=1,
|
1484
1482
|
dynamic_temperature_enabled=True,
|
1485
1483
|
saved_state_path="facebook_realestate_agent.json",
|
@@ -1489,7 +1487,7 @@ agents = [
|
|
1489
1487
|
Agent(
|
1490
1488
|
agent_name="LinkedIn-RealEstate-Agent",
|
1491
1489
|
system_prompt=LINKEDIN_AGENT_SYS_PROMPT,
|
1492
|
-
model_name="gpt-4o",
|
1490
|
+
model_name="gpt-4o-mini",
|
1493
1491
|
max_loops=1,
|
1494
1492
|
dynamic_temperature_enabled=True,
|
1495
1493
|
saved_state_path="linkedin_realestate_agent.json",
|
@@ -1499,7 +1497,7 @@ agents = [
|
|
1499
1497
|
Agent(
|
1500
1498
|
agent_name="Email-RealEstate-Agent",
|
1501
1499
|
system_prompt=EMAIL_AGENT_SYS_PROMPT,
|
1502
|
-
model_name="gpt-4o",
|
1500
|
+
model_name="gpt-4o-mini",
|
1503
1501
|
max_loops=1,
|
1504
1502
|
dynamic_temperature_enabled=True,
|
1505
1503
|
saved_state_path="email_realestate_agent.json",
|
@@ -1963,32 +1961,18 @@ A production-grade multi-agent system enabling sophisticated group conversations
|
|
1963
1961
|
|
1964
1962
|
|
1965
1963
|
```python
|
1966
|
-
|
1967
|
-
import os
|
1968
|
-
from dotenv import load_dotenv
|
1969
|
-
from swarm_models import OpenAIChat
|
1970
1964
|
from swarms import Agent, GroupChat, expertise_based
|
1971
1965
|
|
1972
1966
|
|
1973
1967
|
if __name__ == "__main__":
|
1974
1968
|
|
1975
|
-
load_dotenv()
|
1976
|
-
|
1977
|
-
# Get the OpenAI API key from the environment variable
|
1978
|
-
api_key = os.getenv("OPENAI_API_KEY")
|
1979
|
-
|
1980
|
-
# Create an instance of the OpenAIChat class
|
1981
|
-
model = OpenAIChat(
|
1982
|
-
openai_api_key=api_key,
|
1983
|
-
model_name="gpt-4o-mini",
|
1984
|
-
temperature=0.1,
|
1985
|
-
)
|
1986
1969
|
|
1987
1970
|
# Example agents
|
1988
1971
|
agent1 = Agent(
|
1989
1972
|
agent_name="Financial-Analysis-Agent",
|
1990
1973
|
system_prompt="You are a financial analyst specializing in investment strategies.",
|
1991
|
-
|
1974
|
+
model_name="gpt-4o-mini",
|
1975
|
+
temperature=0.1,
|
1992
1976
|
max_loops=1,
|
1993
1977
|
autosave=False,
|
1994
1978
|
dashboard=False,
|
@@ -2004,7 +1988,8 @@ if __name__ == "__main__":
|
|
2004
1988
|
agent2 = Agent(
|
2005
1989
|
agent_name="Tax-Adviser-Agent",
|
2006
1990
|
system_prompt="You are a tax adviser who provides clear and concise guidance on tax-related queries.",
|
2007
|
-
|
1991
|
+
model_name="gpt-4o-mini",
|
1992
|
+
temperature=0.1,
|
2008
1993
|
max_loops=1,
|
2009
1994
|
autosave=False,
|
2010
1995
|
dashboard=False,
|
@@ -2029,7 +2014,8 @@ if __name__ == "__main__":
|
|
2029
2014
|
history = chat.run(
|
2030
2015
|
"How to optimize tax strategy for investments?"
|
2031
2016
|
)
|
2032
|
-
print(history
|
2017
|
+
print(history)
|
2018
|
+
|
2033
2019
|
|
2034
2020
|
```
|
2035
2021
|
|
@@ -2087,35 +2073,18 @@ if __name__ == "__main__":
|
|
2087
2073
|
----------
|
2088
2074
|
|
2089
2075
|
## Onboarding Session
|
2076
|
+
|
2090
2077
|
Get onboarded now with the creator and lead maintainer of Swarms, Kye Gomez, who will show you how to get started with the installation, usage examples, and starting to build your custom use case! [CLICK HERE](https://cal.com/swarms/swarms-onboarding-session)
|
2091
2078
|
|
2092
2079
|
|
2093
2080
|
---
|
2094
2081
|
|
2095
2082
|
## Documentation
|
2083
|
+
|
2096
2084
|
Documentation is located here at: [docs.swarms.world](https://docs.swarms.world)
|
2097
2085
|
|
2098
2086
|
-----
|
2099
2087
|
|
2100
|
-
## Folder Structure
|
2101
|
-
The swarms package has been meticulously crafted for extreme usability and understanding,the swarms package is split up into various modules such as `swarms.agents` that holds pre-built agents, `swarms.structs` that holds a vast array of structures like `Agent` and multi agent structures. The package is split into various modules, with the most important being `structs`, `tools`, and `agents`.
|
2102
|
-
|
2103
|
-
```sh
|
2104
|
-
├── __init__.py
|
2105
|
-
├── agents/
|
2106
|
-
├── artifacts/
|
2107
|
-
├── client/
|
2108
|
-
├── cli/
|
2109
|
-
├── prompts/
|
2110
|
-
├── schemas/
|
2111
|
-
├── structs/
|
2112
|
-
├── telemetry/
|
2113
|
-
├── tools/
|
2114
|
-
└── utils/
|
2115
|
-
```
|
2116
|
-
|
2117
|
-
----
|
2118
|
-
|
2119
2088
|
## 🫶 Contributions:
|
2120
2089
|
|
2121
2090
|
The easiest way to contribute is to pick any issue with the `good first issue` tag 💪. Read the Contributing guidelines [here](/CONTRIBUTING.md). Bug Report? [File here](https://github.com/swarms/gateway/issues) | Feature Request? [File here](https://github.com/swarms/gateway/issues)
|
@@ -2125,17 +2094,24 @@ Swarms is an open-source project, and contributions are VERY welcome. If you wan
|
|
2125
2094
|
----
|
2126
2095
|
|
2127
2096
|
|
2128
|
-
|
2097
|
+
### Connect With Us
|
2098
|
+
|
2099
|
+
| Platform | Link | Description |
|
2100
|
+
|----------|------|-------------|
|
2101
|
+
| 📚 Documentation | [docs.swarms.world](https://docs.swarms.world) | Official documentation and guides |
|
2102
|
+
| 📝 Blog | [Medium](https://medium.com/@kyeg) | Latest updates and technical articles |
|
2103
|
+
| 💬 Discord | [Join Discord](https://discord.gg/jM3Z6M9uMq) | Live chat and community support |
|
2104
|
+
| 🐦 Twitter | [@kyegomez](https://twitter.com/kyegomez) | Latest news and announcements |
|
2105
|
+
| 👥 LinkedIn | [The Swarm Corporation](https://www.linkedin.com/company/the-swarm-corporation) | Professional network and updates |
|
2106
|
+
| 📺 YouTube | [Swarms Channel](https://www.youtube.com/channel/UC9yXyitkbU_WSy7bd_41SqQ) | Tutorials and demos |
|
2107
|
+
| 🎫 Events | [Sign up here](https://lu.ma/5p2jnc2v) | Join our community events |
|
2108
|
+
|
2109
|
+
|
2110
|
+
|
2111
|
+
## Citation
|
2129
2112
|
|
2130
|
-
|
2113
|
+
If you use **swarms** in your research, please cite the project by referencing the metadata in [CITATION.cff](./CITATION.cff).
|
2131
2114
|
|
2132
|
-
- View our official [Documents](https://docs.swarms.world)
|
2133
|
-
- View our official [Blog](https://medium.com/@kyeg)
|
2134
|
-
- Chat live with us on [Discord](https://discord.gg/jM3Z6M9uMq)
|
2135
|
-
- Follow us on [Twitter](https://twitter.com/kyegomez)
|
2136
|
-
- Connect with us on [LinkedIn](https://www.linkedin.com/company/the-swarm-corporation)
|
2137
|
-
- Visit us on [YouTube](https://www.youtube.com/channel/UC9yXyitkbU_WSy7bd_41SqQ)
|
2138
|
-
- Sign up for our events [Sign up here](https://lu.ma/5p2jnc2v)
|
2139
2115
|
|
2140
2116
|
# License
|
2141
2117
|
|
@@ -2,36 +2,38 @@ swarms/__init__.py,sha256=0tc5msh0Sfk6V_KIwen_4p2kwkHBLjLxZVoAsFE-b80,513
|
|
2
2
|
swarms/agents/__init__.py,sha256=hEp16SuPhlcLX84HAlaK_9RNf6JB0JQ27YTrTnvak04,1171
|
3
3
|
swarms/agents/agent_judge.py,sha256=xT242CX5mV64cq2B-3RGkuEHiV5aD04P_Zq8_s64iMQ,3967
|
4
4
|
swarms/agents/agent_print.py,sha256=SXqWA2ZzXwRFdv8hkuYwOPMTasvaGTG6U29413qRCAA,918
|
5
|
-
swarms/agents/ape_agent.py,sha256=
|
5
|
+
swarms/agents/ape_agent.py,sha256=Ws7PmfCL5ctxIdLjQ-lkTWoYMGMjnqqDuo4chPpsF0w,1046
|
6
6
|
swarms/agents/auto_generate_swarm_config.py,sha256=7eJ873xS7PJmyreMaa5Uub8qFu-qIinuyMuogB2Ehjc,8474
|
7
|
-
swarms/agents/consistency_agent.py,sha256=
|
7
|
+
swarms/agents/consistency_agent.py,sha256=kN7FEaf_HvQP99gJNGWRobFuuF56oArGjWkmxhpRNew,7412
|
8
8
|
swarms/agents/cort_agent.py,sha256=cTorrAcdI46Zvf4RfTouVl4J2vdPSur5CHDWTTMgujU,8002
|
9
9
|
swarms/agents/create_agents_from_yaml.py,sha256=PgFIpuYZehxEl79BAK6TolSZwydDQzvGMAKhLsHuBbc,13008
|
10
10
|
swarms/agents/flexion_agent.py,sha256=Agjq1rvTzboE8lT26-mcjp0tKQEjlUj_eVYsFjLIvN0,21468
|
11
11
|
swarms/agents/gkp_agent.py,sha256=5Jms3zHQ2qwJ6-PHDh9X-cFtAlH4dSUoDgRqN-xZzog,21067
|
12
|
-
swarms/agents/i_agent.py,sha256=
|
12
|
+
swarms/agents/i_agent.py,sha256=_kqGt3a4SGB21_GP-KcV8A5p_9wneShs6eJUJYFdluw,12274
|
13
13
|
swarms/agents/openai_assistant.py,sha256=mTSEtj26J0mc5pCeWrmMY0EXzTRYQfyfw_BtOqtcCHc,11044
|
14
14
|
swarms/agents/react_agent.py,sha256=yM8lQoRsqJZicqtmgBrC7RHv0aKEb5oZHh4q5aAA_xs,5804
|
15
|
-
swarms/agents/reasoning_agents.py,sha256=
|
16
|
-
swarms/agents/reasoning_duo.py,sha256=
|
15
|
+
swarms/agents/reasoning_agents.py,sha256=Z_YETF-hzG7qL-h6WB1qNR6QU4g784M9NzO5C0_kWtA,9639
|
16
|
+
swarms/agents/reasoning_duo.py,sha256=4qw9RtwmWkWnDWjEtJqYFVLh--EV9YQd24-fQa0lMfM,3873
|
17
17
|
swarms/agents/self_agent_builder.py,sha256=bX7xSwak6HiyK901VdeE8OlT4yqE0n7jyHcWJrkMeew,1104
|
18
18
|
swarms/agents/tool_agent.py,sha256=G7rhBACsHsGUMT4H9eF5aY7e3Gx-5jOmJkhCF1jm9mU,5087
|
19
19
|
swarms/artifacts/__init__.py,sha256=M111xTw7IVVt8gLDwW7Kau5n1YdwkL3vbCJPVeEWktI,83
|
20
20
|
swarms/artifacts/main_artifact.py,sha256=bu2TcsTR81ttJEjVJ3NzT7D4x7uuM57okC92QuigV9I,11139
|
21
21
|
swarms/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
22
22
|
swarms/cli/create_agent.py,sha256=o2V6EDQN477MxUOm0wShlr4uNyPpPzqpJhGM5tiuWUU,1128
|
23
|
-
swarms/cli/main.py,sha256=
|
23
|
+
swarms/cli/main.py,sha256=gyq8rnYn94kD302lAkFnWTI-_ZSp_1pMJfhdjQHJ2K8,15309
|
24
24
|
swarms/cli/onboarding_process.py,sha256=3-2LKoLhjnaPbX9iiasqXPZZpqmwm-ZrXawH88M4BIU,6940
|
25
|
-
swarms/communication/__init__.py,sha256=
|
25
|
+
swarms/communication/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
26
26
|
swarms/communication/base_communication.py,sha256=0aQavvEQv24MHvulZ2mGVmQ9hkqROSIW608wfo8-P9s,8559
|
27
|
-
swarms/communication/duckdb_wrap.py,sha256=
|
28
|
-
swarms/communication/pulsar_struct.py,sha256=
|
29
|
-
swarms/communication/redis_wrap.py,sha256=
|
27
|
+
swarms/communication/duckdb_wrap.py,sha256=1_uC1DFsy0rHqgCCT5ZdzGM9hf9iko3BruA3vwajXlw,45563
|
28
|
+
swarms/communication/pulsar_struct.py,sha256=jOSNdWSDO-eqtXL9x77TG3AU2eR7lxlT2xkcTKExx3Q,24684
|
29
|
+
swarms/communication/redis_wrap.py,sha256=qMiqVmTk0Zs-8zqe6p8EPSKbjyAsBws0apbALvB8wHs,48631
|
30
30
|
swarms/communication/sqlite_wrap.py,sha256=PD7p5bdTjK6a7yqdlAJtgduO9WdAb_wJpQlCSH6gbG0,43604
|
31
|
+
swarms/communication/supabase_wrap.py,sha256=NRdaZ-TIU95sCuGYBGn0zwNsGealepKyZAYqc62nBs4,63917
|
31
32
|
swarms/prompts/__init__.py,sha256=ZFcghAs4b0Rsjcc_DIFssiztZub5tJ66rxmJD2_tXpQ,747
|
32
33
|
swarms/prompts/accountant_swarm_prompts.py,sha256=swceN1B0fZCOedd3-y3gjNOHDmR-3H5YK17ytp7tTDM,11320
|
33
34
|
swarms/prompts/ag_prompt.py,sha256=mMeqC84SMNrCjQcBeejroSXLuF_wWrVRebHU1MrEQko,4577
|
34
35
|
swarms/prompts/aga.py,sha256=4rRG7r9LF9JBrGOLN4Hy_6cSe0z5YOeKFbGnOmRfFJ0,9156
|
36
|
+
swarms/prompts/agent_conversation_aggregator.py,sha256=B7fi8INZUV2OLLYAfn9P8ghzDRfb6CqDdffzgvX3crE,2161
|
35
37
|
swarms/prompts/agent_judge_prompt.py,sha256=-2q5mWLRyO7pj7j512ZNYRm-uEZttPgDGaxZo3oM_QQ,2235
|
36
38
|
swarms/prompts/agent_prompt.py,sha256=6SXkMWcFIIAY02N9P6kMdzo4wtPwzg1Bl9R2qsIdicM,2705
|
37
39
|
swarms/prompts/agent_prompts.py,sha256=63ZqAO1jfH3TKtl9ibLLagSG5kAPlbq4xtCGgGEuuoA,6886
|
@@ -65,7 +67,7 @@ swarms/prompts/personal_stylist.py,sha256=_14TSdWdHs6WCnBSK5--1QXcHv5qK466O6A781
|
|
65
67
|
swarms/prompts/product_agent_prompt.py,sha256=RN24ZeXA-QEVYWFoobJRtpXzQJ0shPhcUpCbNLkArTc,8333
|
66
68
|
swarms/prompts/programming.py,sha256=Bg_PV5CexJFLqadJjjliU6t89q8IeQTEp2ZyEF9kO0g,10144
|
67
69
|
swarms/prompts/project_manager.py,sha256=EfJGlH4YNX8kbFz-vAJXEEhBOD5QKvl7TPjU7aoapec,2128
|
68
|
-
swarms/prompts/prompt.py,sha256=
|
70
|
+
swarms/prompts/prompt.py,sha256=ktlZkk5wMLqE9YMtb2Y3Gdg2ahPaIetoyEfgbge4-yg,9414
|
69
71
|
swarms/prompts/prompt_generator.py,sha256=56xRcy9J86c-Z18HGKExsArVff2AdmmSDs7C8nPkA_w,4412
|
70
72
|
swarms/prompts/prompt_generator_optimizer.py,sha256=ODhXgN4cIHbuuSOPrt1iTzntKeQm71hNUiZsqf-gj1M,3823
|
71
73
|
swarms/prompts/python.py,sha256=JgykzeNYLHHVvjoTR5FhZEVWJFc3SWCMgf-mRN3yMEo,13215
|
@@ -91,63 +93,70 @@ swarms/prompts/worker_prompt.py,sha256=f6qPN24vEciGRTHyYjNDguhzCFPZqa2u05rEHIPcJ
|
|
91
93
|
swarms/prompts/xray_swarm_prompt.py,sha256=AfV_y8GVuEodznOGQ9Q8QlInoLE5Px3Nl9GS_EpsDxg,2349
|
92
94
|
swarms/schemas/__init__.py,sha256=G2PKMJONzT3x6_edNqNjTgCgpTyul4UKhpC5cSe8Zjw,247
|
93
95
|
swarms/schemas/agent_class_schema.py,sha256=SG04rPZEHE4XWwC402qvfRMRJpyhQ0AvsHF-_B-e2Cg,4581
|
96
|
+
swarms/schemas/agent_completion_response.py,sha256=-CcDrSj9DtyTWpX8LbCAgazVLoXRX3Drzpb9lshKRl8,2232
|
94
97
|
swarms/schemas/agent_mcp_errors.py,sha256=2BDsZAt9Pgmfh_D5DKY5vc9psw4Wl0FevL60yfiQvKk,266
|
98
|
+
swarms/schemas/agent_rag_schema.py,sha256=8KZYDJkecg24rqOaeKAlDKLoYlw31m_S0k-ra_ilz_w,124
|
95
99
|
swarms/schemas/agent_step_schemas.py,sha256=a14gb58vR0xOwB_fwSJQbN6yb9HddEaT30E6hUrzEQA,2573
|
96
100
|
swarms/schemas/agent_tool_schema.py,sha256=XdaKie6R0WhNXlnEl9f5T3hHmMedFbVwG17fdHP_U3E,385
|
97
101
|
swarms/schemas/base_schemas.py,sha256=UvBLVWg2qRen4tK5GJz50v42SiX95EQ5qK7hfyAHTEU,3267
|
98
|
-
swarms/schemas/
|
102
|
+
swarms/schemas/conversation_schema.py,sha256=eOJhaRBJw4Z0PWXx9ljRIL0byR_pFIU-6k3UIWli8JA,325
|
103
|
+
swarms/schemas/llm_agent_schema.py,sha256=S5ZIF21q-I9EUtQpgKYZc361o5FGFOnrW_6YTKNYlMY,3568
|
99
104
|
swarms/schemas/mcp_schemas.py,sha256=XZJ4HyiY_cv8Gvj-53ddjzXuqT9hBU2f0cHbhIKs_jY,1330
|
100
|
-
swarms/
|
101
|
-
swarms/
|
105
|
+
swarms/schemas/swarms_api_schemas.py,sha256=uKqleW_7hNpqHi06yoba9jS2i9yzZp-SBV944MnkN68,6233
|
106
|
+
swarms/schemas/tool_schema_base_model.py,sha256=0biTGIoibsPPP3fOrkC6WvNU5vXaalyccVKC1fpO_eg,1409
|
107
|
+
swarms/structs/__init__.py,sha256=XbUK6MSivL9qHNFlcoGcAVRYPupQssD3dG_-yAqrycw,4345
|
108
|
+
swarms/structs/agent.py,sha256=dwCuxBLpPEvJCREfsMbp_Imiz_VtFiZTuXZMrWduIAE,102867
|
102
109
|
swarms/structs/agent_builder.py,sha256=tYNpfO4_8cgfMHfgA5DAOWffHnt70p6CLt59esqfVCY,12133
|
110
|
+
swarms/structs/agent_rag_handler.py,sha256=g17YRrNmf16TLvyFCCcsitVk3d-QNZmck_XYmjSN_YM,21372
|
103
111
|
swarms/structs/agent_registry.py,sha256=il507cO1NF-d4ChyANVLuWrN8bXsEAi8_7bLJ_sTU6A,12112
|
104
112
|
swarms/structs/agent_roles.py,sha256=8XEw6RjOOZelaZaWt4gXaYQm5WMLEhSO7W6Z8sQjmFg,582
|
105
113
|
swarms/structs/agent_router.py,sha256=YZw5AaK2yTvxkOA7ouED_4MoYgn0XZggvo1wrglp-4E,13017
|
106
114
|
swarms/structs/aop.py,sha256=VQS1oDtg4cXVBxRaxMSYSM5X4nzVFy7u7mLmiOqDWZo,17408
|
107
115
|
swarms/structs/auto_swarm_builder.py,sha256=79hd-3GpEyCGgS6tj4FvGFyM8768McQZJQXbGGj9XMk,12973
|
108
116
|
swarms/structs/base_structure.py,sha256=GDu4QJQQmhU7IyuFJHIh9UVThACCva-L7uoMbVD9l4s,15901
|
109
|
-
swarms/structs/base_swarm.py,sha256=
|
117
|
+
swarms/structs/base_swarm.py,sha256=bO5olk16je7aJ_XmJxiD6y4nVlbvOySZpc5JX6Rdpvg,23807
|
110
118
|
swarms/structs/base_workflow.py,sha256=DTfFwX3AdFYxACDYwUDqhsbcDZnITlg5TeEYyxmJBCc,11414
|
111
119
|
swarms/structs/batch_agent_execution.py,sha256=d85DzeCq4uTbbPqLhAXFqFx_cxXUS5yRnJ1-gJkwU5w,1871
|
112
120
|
swarms/structs/concat.py,sha256=utezSxNyh1mIwXgdf8-dJ803NDPyEy79WE8zJHuooGk,732
|
113
121
|
swarms/structs/concurrent_workflow.py,sha256=OqXI-X-9a0hG2a7aLzobwd7CVF2ez0rgLj3ZHqri5bg,12952
|
114
|
-
swarms/structs/conversation.py,sha256=
|
122
|
+
swarms/structs/conversation.py,sha256=EagQYlcLoa4Kukb5oQnLDQqpM7-HnIeLNepubIk8ono,49225
|
115
123
|
swarms/structs/council_judge.py,sha256=siYDKiHMvFmShUTXxdo4R6vXiQhKt7bEBI205oC3kU4,19639
|
116
|
-
swarms/structs/csv_to_agent.py,sha256=
|
124
|
+
swarms/structs/csv_to_agent.py,sha256=PVSbLdWqt6VnnekwqcnWQ8-Am3bhNFsIkUK5GliZV18,11178
|
117
125
|
swarms/structs/de_hallucination_swarm.py,sha256=9cC0rSSXGwYu6SRDwpeMbCcQ40C1WI1RE9SNapKRLOQ,10309
|
118
|
-
swarms/structs/deep_research_swarm.py,sha256=
|
119
|
-
swarms/structs/dynamic_conversational_swarm.py,sha256=
|
126
|
+
swarms/structs/deep_research_swarm.py,sha256=cNLDI7_lT47q4bCRlMJO4IAO3Fu_iF3nPi3jgtg6CJQ,17026
|
127
|
+
swarms/structs/dynamic_conversational_swarm.py,sha256=xm8x_0OCI4ijatgVt8dzHhLNUyMzqG2U_XQL14kcIS8,8354
|
120
128
|
swarms/structs/graph_workflow.py,sha256=TAaUG_J3898hhghPOp0WEAV3Zf0in6s48ZSVbSTX-vQ,8629
|
121
129
|
swarms/structs/groupchat.py,sha256=jjH0BqU9Nrd_3jl9QzrcvbSce527SFpUaepawaRiw2o,15391
|
122
|
-
swarms/structs/hiearchical_swarm.py,sha256=
|
123
|
-
swarms/structs/hybrid_hiearchical_peer_swarm.py,sha256=
|
130
|
+
swarms/structs/hiearchical_swarm.py,sha256=6JwYWlsmwsVtOr2xlzl2q0IRsGvr-RFzDG9ClIJWTQo,33400
|
131
|
+
swarms/structs/hybrid_hiearchical_peer_swarm.py,sha256=0BrmzSVit-I_04DFfrs7onLblLA6PSPa0JE3-4j05FA,9316
|
132
|
+
swarms/structs/image_batch_processor.py,sha256=31Z8vTVL4dw18QxGwb0Jg1nvp0YzX8lwVgGj_-KrkhY,8207
|
133
|
+
swarms/structs/interactive_groupchat.py,sha256=tt5JCqYsLK-omFz-eG-HBEttvu3zMLAprbLEahVWb6M,12937
|
124
134
|
swarms/structs/long_agent.py,sha256=KFjE2uUI8ONTkeJO43Sh3y5-Ec0kga28BECGklic-S4,15049
|
135
|
+
swarms/structs/ma_blocks.py,sha256=04dF3DOSHXxNwrcl9QUloKgNDkI9yLRv6UbyyiKsIb0,4551
|
125
136
|
swarms/structs/ma_utils.py,sha256=s8uTCplQtiFvxyqyTTTUCnJDMwNLJEuxbdGZyOURjLg,3244
|
126
|
-
swarms/structs/majority_voting.py,sha256=
|
137
|
+
swarms/structs/majority_voting.py,sha256=7RGMTNX-ulH5McV0LPkpGEOkwYgsBdzTzHk5G_g_YUY,10120
|
127
138
|
swarms/structs/malt.py,sha256=uLofKBWHkP3uNhyCkkgEyE4Z7qnOHTtcg-OTiR19x_Y,19572
|
128
139
|
swarms/structs/matrix_swarm.py,sha256=qHuhOYrTyOv6ujHMe8PrQT-h-WmaCPCfX4ghv5L8UFI,9765
|
129
140
|
swarms/structs/meme_agent_persona_generator.py,sha256=b3kKlumhsV4KV88-GS3CUnGO1UfKTU3fT8SAMj0ZlwQ,10645
|
130
|
-
swarms/structs/mixture_of_agents.py,sha256=
|
141
|
+
swarms/structs/mixture_of_agents.py,sha256=UtEwfv0GY-RU32AwVKU1j9XJvBZx8IioTgGxaIki4qU,7760
|
131
142
|
swarms/structs/model_router.py,sha256=V5pZHYlxSmCvAA2Gsns7LaCz8dXtRi7pCvb-oLGHYIY,12739
|
132
|
-
swarms/structs/
|
133
|
-
swarms/structs/
|
134
|
-
swarms/structs/multi_agent_router.py,sha256=21PfswEuxMHqlWDBCyritj9UuHTShYVQRaK0o23eia8,10999
|
143
|
+
swarms/structs/multi_agent_exec.py,sha256=3hIGgwJ_mQwgD16N096jN48-DEIZWFPoetR2nCxIe6I,14203
|
144
|
+
swarms/structs/multi_agent_router.py,sha256=A4MDd4_QAoarrLaxClnCxnEP62bSMFvyq77ttqeq3u8,11049
|
135
145
|
swarms/structs/multi_model_gpu_manager.py,sha256=gHC6MmVia4etMD6RlpEdbqZtV7ng4f-6jVMH0Zrt8y4,47356
|
136
146
|
swarms/structs/omni_agent_types.py,sha256=RdKLfZ-lXDJrEa0aJT_Rfx9TypJQo8SISqKz4fnLkAk,230
|
137
|
-
swarms/structs/
|
138
|
-
swarms/structs/rearrange.py,sha256=5u7HwTVVH414w9rhEQvLdltW1ACHjgwn-zS8-8JEXmA,22576
|
147
|
+
swarms/structs/rearrange.py,sha256=x8dU19blC2ED8xEi1NPF5_GMgsupKbZ08nVVEQEGmaQ,22598
|
139
148
|
swarms/structs/round_robin.py,sha256=MGk623KiN9uSxTMG6MY_BIAkvEDh1RPwyl5Min7GLOU,7573
|
140
149
|
swarms/structs/safe_loading.py,sha256=gmYX8G9TsvAIp6OCvREBZt5mwSFc-p-t1rSnDBfhEmE,7124
|
141
|
-
swarms/structs/sequential_workflow.py,sha256=
|
150
|
+
swarms/structs/sequential_workflow.py,sha256=CP-MmxSEJpQCJFivegQyK0GTff5k3jFZbso3t3bSu00,8524
|
142
151
|
swarms/structs/spreadsheet_swarm.py,sha256=ToX56QJjlm_nnC3MYppvKC_NTr9Zy_orkBzfxNLdwbA,14845
|
143
152
|
swarms/structs/stopping_conditions.py,sha256=JHHwqgPoUvjX897ofW2gpPZH_cqEWmv5lDTqb2GtA6M,1382
|
144
153
|
swarms/structs/swarm_arange.py,sha256=5ewEfL52Y4gh-a0lRjFcleHWlsCBuc5XR1nVEEGh07w,15481
|
145
154
|
swarms/structs/swarm_eval.py,sha256=148E2R2zaCmt_LZYx15nmdFjybXHiQ2CZbl6pk77jNs,11635
|
146
155
|
swarms/structs/swarm_id_generator.py,sha256=Wly7AtGM9e6VgzhYmfg8_gSOdxAdsOvWHJFK81cpQNQ,68
|
147
|
-
swarms/structs/swarm_matcher.py,sha256=
|
156
|
+
swarms/structs/swarm_matcher.py,sha256=HUCxTWRnxT5Rix3CMKEuJCqNleqPA9xGrWFGw6rjcTw,26821
|
148
157
|
swarms/structs/swarm_registry.py,sha256=P0XRrqp1qBNyt0BycqPQljUzKv9jClaQMhtaBMinhYg,5578
|
149
|
-
swarms/structs/swarm_router.py,sha256=
|
150
|
-
swarms/structs/swarming_architectures.py,sha256=
|
158
|
+
swarms/structs/swarm_router.py,sha256=2ytmiQH-slqtQts0JPju52jTLTHRDNgdV-tjp0-TtAg,27813
|
159
|
+
swarms/structs/swarming_architectures.py,sha256=guNQU2N7Ofuk01fZbU3tmBJymnZ9zdGULpPZAdaqCeA,28276
|
151
160
|
swarms/structs/tree_swarm.py,sha256=AnIxrt0KhWxAQN8uGjfCcOq-XCmsuTJiH8Ex4mXy8V8,12500
|
152
161
|
swarms/structs/utils.py,sha256=Mo6wHQYOB8baWZUKnAJN5Dsgubpo81umNwJIEDitb2A,1873
|
153
162
|
swarms/structs/various_alt_swarms.py,sha256=qdBuOF31UjatlKRu-9bxwyRQzIjohRhTv_63YoUeYEY,27866
|
@@ -164,42 +173,40 @@ swarms/tools/function_util.py,sha256=DAnAPO0Ik__TAqL7IJzFmkukHnhpsW_QtALl3yj837g
|
|
164
173
|
swarms/tools/json_former.py,sha256=4ugLQ_EZpghhuhFsVKsy-ehin9K64pqVE2gLU7BTO_M,14376
|
165
174
|
swarms/tools/json_utils.py,sha256=WKMZjcJ0Vt6lgIjiTBenslcfjgRSLX4UWs4uDkKFMQI,1316
|
166
175
|
swarms/tools/logits_processor.py,sha256=NifZZ5w9yemWGJAJ5nHFrphtZVX1XlyesgvYZTxK1GM,2965
|
167
|
-
swarms/tools/mcp_client_call.py,sha256=
|
176
|
+
swarms/tools/mcp_client_call.py,sha256=8cLwtOAYSRGdCRYq_RujuyLHcApQXmNp6K9vYtv1N6U,15362
|
168
177
|
swarms/tools/openai_func_calling_schema_pydantic.py,sha256=6BAH9kuaVTvJIbjgSSJ5XvHhWvWszPxgarkfUuE5Ads,978
|
169
178
|
swarms/tools/openai_tool_creator_decorator.py,sha256=SYZjHnARjWvnH9cBdj7Kc_Yy1muvNxMT3RQz8KkA2SE,2578
|
170
179
|
swarms/tools/py_func_to_openai_func_str.py,sha256=sjoNutRZ11-0kYFDalUTxZxQ0TEDyn5R8EXMdS4gsgw,17091
|
171
180
|
swarms/tools/pydantic_to_json.py,sha256=sd5uWwjSHsu7M8wCBrPv0uje05-K4xcfbvKQ_zOaww8,3399
|
172
181
|
swarms/tools/tool_parse_exec.py,sha256=FW5XzkuNEs2YrroybjKChbCzDvaCs7ypknSDpYhfkd4,8717
|
173
182
|
swarms/tools/tool_registry.py,sha256=ULZmIKBTx9XRCJRD9hwXfY3iQw9v94arw-VV6jcuftY,7992
|
174
|
-
swarms/tools/tool_schema_base_model.py,sha256=0biTGIoibsPPP3fOrkC6WvNU5vXaalyccVKC1fpO_eg,1409
|
175
183
|
swarms/tools/tool_utils.py,sha256=yXzzqG7Ytd8ybB8bsjNUNLaXIuIp9JbbpUKCiHxQqo8,2816
|
176
|
-
swarms/utils/__init__.py,sha256=
|
184
|
+
swarms/utils/__init__.py,sha256=tpbhE-BTISDMXemSRSRJz-Rz7m_C05Q5Pre3d9H9SN4,1195
|
177
185
|
swarms/utils/any_to_str.py,sha256=Qi4N9ed6LYnCs2AeFYo1zwEfYhOKUesGVFUmVUz54KI,2936
|
178
186
|
swarms/utils/audio_processing.py,sha256=Y3KaWG9WJrgquWCeaty20HWPIXfeuPAhcJFzoSBIQjE,9893
|
179
187
|
swarms/utils/auto_download_check_packages.py,sha256=mqx3jCetfkTuxTdeGLx-gGMB1xWOU5vata8lTKXLatk,4580
|
180
188
|
swarms/utils/calculate_func_metrics.py,sha256=Nb5r7rWf809m5F7mWIYXZ0H_WeyGr78A2UZD2GHtJkM,5007
|
189
|
+
swarms/utils/check_all_model_max_tokens.py,sha256=ZHIKlrU-L-OM2IJAbYkCoVyBKe2d0JrGhDC9QNppGIs,1519
|
181
190
|
swarms/utils/data_to_text.py,sha256=1PUoWokylp7MOrGNk1cmO3cJlfskdAIiImGk9ECwsKU,3427
|
182
191
|
swarms/utils/disable_logging.py,sha256=KKPKQVfQqLPFgj03uveOoyeHOTlfEJt-yfLc3SA53Rk,2470
|
183
192
|
swarms/utils/file_processing.py,sha256=QjQCIPTcwicQlfy656BXBYpIzMR0s2343E7ftnok5Uo,4865
|
184
193
|
swarms/utils/formatter.py,sha256=e15FsyTIIkyRreMUApkkZCzJC1Sm67w5Zd6EQcUkMwA,4533
|
185
194
|
swarms/utils/function_caller_model.py,sha256=ZfgCMzOizNnuZipYLclTziECNHszH9p8RQcUq7VNr4Q,4156
|
186
|
-
swarms/utils/generate_keys.py,sha256=
|
187
|
-
swarms/utils/history_output_formatter.py,sha256=
|
195
|
+
swarms/utils/generate_keys.py,sha256=o5zp_8rwu5sgQnItWS1xAuIIRIkahwm02qy1vsV6DSQ,997
|
196
|
+
swarms/utils/history_output_formatter.py,sha256=hxRVeusMxcwIPcbPpsmWgxd7PGxBv2eJzUDITbyFvKE,1309
|
188
197
|
swarms/utils/index.py,sha256=iYVlMiuSpBuKHF34uSrxDUuSYmS26bbYoAqyz_VIyvY,6902
|
189
198
|
swarms/utils/litellm_tokenizer.py,sha256=PqzAY4C5lJ3P-K9SL-dCNtxmHHlZvAw1UohT-ob9lxY,3389
|
190
|
-
swarms/utils/litellm_wrapper.py,sha256=
|
199
|
+
swarms/utils/litellm_wrapper.py,sha256=moSaVYIViCSib2r1kS2h1BqltQKcysVJCeI6cAXp2bU,19566
|
191
200
|
swarms/utils/loguru_logger.py,sha256=hIoSK3NHLpe7eAmjHRURrEYzNXYC2gbR7_Vv63Yaydk,685
|
192
|
-
swarms/utils/
|
201
|
+
swarms/utils/output_types.py,sha256=yEggBESV8D-gOh7NR6OpOT0WUmA97oz514f27B9NV1Y,406
|
193
202
|
swarms/utils/parse_code.py,sha256=XFOLymbdP3HzMZuqsj7pwUyisvUmTm0ev9iThR_ambI,1987
|
194
203
|
swarms/utils/pdf_to_text.py,sha256=nkySOS_sJ4Jf4RP5SoDpMB5WfjJ_GGc5z8gJfn2cxOM,1311
|
195
204
|
swarms/utils/str_to_dict.py,sha256=T3Jsdjz87WIlkSo7jAW6BB80sv0Ns49WT1qXlOrdEoE,874
|
196
205
|
swarms/utils/try_except_wrapper.py,sha256=uvDZDZJcH986EF0Ej6zZBLcqHJ58NHizPsAH5olrE7Q,3919
|
197
|
-
swarms/utils/
|
198
|
-
swarms/utils/
|
199
|
-
swarms/
|
200
|
-
swarms/
|
201
|
-
swarms-7.8.
|
202
|
-
swarms-7.8.
|
203
|
-
swarms-7.8.
|
204
|
-
swarms-7.8.3.dist-info/entry_points.txt,sha256=2K0rTtfO1X1WaO-waJlXIKw5Voa_EpAL_yU0HXE2Jgc,47
|
205
|
-
swarms-7.8.3.dist-info/RECORD,,
|
206
|
+
swarms/utils/vllm_wrapper.py,sha256=sNkm4EbeMrqqmHidnvq5zTnofQAaARy3HIrNBu11lKs,5072
|
207
|
+
swarms/utils/xml_utils.py,sha256=D4nEdo1nkHqSoTKrWylXBXjcHFhGaOYvvfGNQQoYV5o,2514
|
208
|
+
swarms-7.8.7.dist-info/LICENSE,sha256=jwRtEmTWjLrEsvFB6QFdYs2cEeZPRMdj-UMOFkPF8_0,11363
|
209
|
+
swarms-7.8.7.dist-info/METADATA,sha256=ysQ9oCgqZ8C76O62Z3g0L_RSZOq-4iyw_yjVdUYrAhk,94363
|
210
|
+
swarms-7.8.7.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
211
|
+
swarms-7.8.7.dist-info/entry_points.txt,sha256=2K0rTtfO1X1WaO-waJlXIKw5Voa_EpAL_yU0HXE2Jgc,47
|
212
|
+
swarms-7.8.7.dist-info/RECORD,,
|
@@ -1,242 +0,0 @@
|
|
1
|
-
from typing import List, Callable
|
2
|
-
|
3
|
-
from swarms.structs.agent import Agent
|
4
|
-
from swarms.utils.loguru_logger import logger
|
5
|
-
from swarms.structs.base_swarm import BaseSwarm
|
6
|
-
from swarms.structs.conversation import Conversation
|
7
|
-
|
8
|
-
|
9
|
-
# def select_next_speaker_bid(
|
10
|
-
# step: int,
|
11
|
-
# agents: List[Agent],
|
12
|
-
# ) -> int:
|
13
|
-
# """Selects the next speaker."""
|
14
|
-
# bids = []
|
15
|
-
# for agent in agents:
|
16
|
-
# bid = ask_for_bid(agent)
|
17
|
-
# bids.append(bid)
|
18
|
-
# max_value = max(bids)
|
19
|
-
# max_indices = [i for i, x in enumerate(bids) if x == max_value]
|
20
|
-
# idx = random.choice(max_indices)
|
21
|
-
# return idx
|
22
|
-
|
23
|
-
|
24
|
-
def select_next_speaker_roundtable(
|
25
|
-
step: int, agents: List[Agent]
|
26
|
-
) -> int:
|
27
|
-
"""Selects the next speaker."""
|
28
|
-
return step % len(agents)
|
29
|
-
|
30
|
-
|
31
|
-
def select_next_speaker_director(
|
32
|
-
step: int, agents: List[Agent], director: Agent
|
33
|
-
) -> int:
|
34
|
-
# if the step if even => director
|
35
|
-
# => director selects next speaker
|
36
|
-
if step % 2 == 1:
|
37
|
-
idx = 0
|
38
|
-
else:
|
39
|
-
idx = director.select_next_speaker() + 1
|
40
|
-
return idx
|
41
|
-
|
42
|
-
|
43
|
-
def run_director(self, task: str):
|
44
|
-
"""Runs the multi-agent collaboration with a director."""
|
45
|
-
n = 0
|
46
|
-
self.reset()
|
47
|
-
self.inject("Debate Moderator", task)
|
48
|
-
print("(Debate Moderator): \n")
|
49
|
-
|
50
|
-
while n < self.max_loops:
|
51
|
-
name, message = self.step()
|
52
|
-
print(f"({name}): {message}\n")
|
53
|
-
n += 1
|
54
|
-
|
55
|
-
|
56
|
-
# [MAYBE]: Add type hints
|
57
|
-
class MultiAgentCollaboration(BaseSwarm):
|
58
|
-
"""
|
59
|
-
Multi-agent collaboration class.
|
60
|
-
|
61
|
-
Attributes:
|
62
|
-
agents (List[Agent]): The agents in the collaboration.
|
63
|
-
selection_function (callable): The function that selects the next speaker.
|
64
|
-
Defaults to select_next_speaker.
|
65
|
-
max_loops (int): The maximum number of iterations. Defaults to 10.
|
66
|
-
autosave (bool): Whether to autosave the state of all agents. Defaults to True.
|
67
|
-
saved_file_path_name (str): The path to the saved file. Defaults to
|
68
|
-
"multi_agent_collab.json".
|
69
|
-
stopping_token (str): The token that stops the collaboration. Defaults to
|
70
|
-
"<DONE>".
|
71
|
-
results (list): The results of the collaboration. Defaults to [].
|
72
|
-
logger (logging.Logger): The logger. Defaults to logger.
|
73
|
-
logging (bool): Whether to log the collaboration. Defaults to True.
|
74
|
-
|
75
|
-
|
76
|
-
Methods:
|
77
|
-
reset: Resets the state of all agents.
|
78
|
-
inject: Injects a message into the collaboration.
|
79
|
-
inject_agent: Injects an agent into the collaboration.
|
80
|
-
step: Steps through the collaboration.
|
81
|
-
ask_for_bid: Asks an agent for a bid.
|
82
|
-
select_next_speaker: Selects the next speaker.
|
83
|
-
run: Runs the collaboration.
|
84
|
-
format_results: Formats the results of the run method.
|
85
|
-
|
86
|
-
|
87
|
-
Usage:
|
88
|
-
>>> from swarm_models import OpenAIChat
|
89
|
-
>>> from swarms.structs import Agent
|
90
|
-
>>> from swarms.swarms.multi_agent_collab import MultiAgentCollaboration
|
91
|
-
>>>
|
92
|
-
>>> # Initialize the language model
|
93
|
-
>>> llm = OpenAIChat(
|
94
|
-
>>> temperature=0.5,
|
95
|
-
>>> )
|
96
|
-
>>>
|
97
|
-
>>>
|
98
|
-
>>> ## Initialize the workflow
|
99
|
-
>>> agent = Agent(llm=llm, max_loops=1, dashboard=True)
|
100
|
-
>>>
|
101
|
-
>>> # Run the workflow on a task
|
102
|
-
>>> out = agent.run("Generate a 10,000 word blog on health and wellness.")
|
103
|
-
>>>
|
104
|
-
>>> # Initialize the multi-agent collaboration
|
105
|
-
>>> swarm = MultiAgentCollaboration(
|
106
|
-
>>> agents=[agent],
|
107
|
-
>>> max_loops=4,
|
108
|
-
>>> )
|
109
|
-
>>>
|
110
|
-
>>> # Run the multi-agent collaboration
|
111
|
-
>>> swarm.run()
|
112
|
-
>>>
|
113
|
-
>>> # Format the results of the multi-agent collaboration
|
114
|
-
>>> swarm.format_results(swarm.results)
|
115
|
-
|
116
|
-
"""
|
117
|
-
|
118
|
-
def __init__(
|
119
|
-
self,
|
120
|
-
name: str = "MultiAgentCollaboration",
|
121
|
-
description: str = "A multi-agent collaboration.",
|
122
|
-
director: Agent = None,
|
123
|
-
agents: List[Agent] = None,
|
124
|
-
select_next_speaker: Callable = None,
|
125
|
-
max_loops: int = 10,
|
126
|
-
autosave: bool = True,
|
127
|
-
saved_file_path_name: str = "multi_agent_collab.json",
|
128
|
-
stopping_token: str = "<DONE>",
|
129
|
-
logging: bool = True,
|
130
|
-
*args,
|
131
|
-
**kwargs,
|
132
|
-
):
|
133
|
-
super().__init__(
|
134
|
-
name=name,
|
135
|
-
description=description,
|
136
|
-
agents=agents,
|
137
|
-
*args,
|
138
|
-
**kwargs,
|
139
|
-
)
|
140
|
-
self.name = name
|
141
|
-
self.description = description
|
142
|
-
self.director = director
|
143
|
-
self.agents = agents
|
144
|
-
self.select_next_speaker = select_next_speaker
|
145
|
-
self._step = 0
|
146
|
-
self.max_loops = max_loops
|
147
|
-
self.autosave = autosave
|
148
|
-
self.saved_file_path_name = saved_file_path_name
|
149
|
-
self.stopping_token = stopping_token
|
150
|
-
self.results = []
|
151
|
-
self.logger = logger
|
152
|
-
self.logging = logging
|
153
|
-
|
154
|
-
# Conversation
|
155
|
-
self.conversation = Conversation(
|
156
|
-
time_enabled=False, *args, **kwargs
|
157
|
-
)
|
158
|
-
|
159
|
-
def default_select_next_speaker(
|
160
|
-
self, step: int, agents: List[Agent]
|
161
|
-
) -> int:
|
162
|
-
"""Default speaker selection function."""
|
163
|
-
return step % len(agents)
|
164
|
-
|
165
|
-
def inject(self, name: str, message: str):
|
166
|
-
"""Injects a message into the multi-agent collaboration."""
|
167
|
-
for agent in self.agents:
|
168
|
-
self.conversation.add(name, message)
|
169
|
-
agent.run(self.conversation.return_history_as_string())
|
170
|
-
self._step += 1
|
171
|
-
|
172
|
-
def step(self) -> str:
|
173
|
-
"""Steps through the multi-agent collaboration."""
|
174
|
-
speaker_idx = self.select_next_speaker(
|
175
|
-
self._step, self.agents
|
176
|
-
)
|
177
|
-
speaker = self.agents[speaker_idx]
|
178
|
-
message = speaker.send()
|
179
|
-
|
180
|
-
for receiver in self.agents:
|
181
|
-
self.conversation.add(speaker.name, message)
|
182
|
-
receiver.run(self.conversation.return_history_as_string())
|
183
|
-
|
184
|
-
self._step += 1
|
185
|
-
|
186
|
-
if self.logging:
|
187
|
-
self.log_step(speaker, message)
|
188
|
-
|
189
|
-
return self.conversation.return_history_as_string()
|
190
|
-
|
191
|
-
def log_step(self, speaker: str, response: str):
|
192
|
-
"""Logs the step of the multi-agent collaboration."""
|
193
|
-
self.logger.info(f"{speaker.name}: {response}")
|
194
|
-
|
195
|
-
def run(self, task: str, *args, **kwargs):
|
196
|
-
"""Runs the multi-agent collaboration."""
|
197
|
-
for _ in range(self.max_loops):
|
198
|
-
result = self.step()
|
199
|
-
if self.autosave:
|
200
|
-
self.save_state()
|
201
|
-
if self.stopping_token in result:
|
202
|
-
break
|
203
|
-
return self.conversation.return_history_as_string()
|
204
|
-
|
205
|
-
# def format_results(self, results):
|
206
|
-
# """Formats the results of the run method"""
|
207
|
-
# formatted_results = "\n".join(
|
208
|
-
# [
|
209
|
-
# f"{result['agent']} responded: {result['response']}"
|
210
|
-
# for result in results
|
211
|
-
# ]
|
212
|
-
# )
|
213
|
-
# return formatted_results
|
214
|
-
|
215
|
-
# def save(self):
|
216
|
-
# """Saves the state of all agents."""
|
217
|
-
# state = {
|
218
|
-
# "step": self._step,
|
219
|
-
# "results": [
|
220
|
-
# {"agent": r["agent"].name, "response": r["response"]}
|
221
|
-
# for r in self.results
|
222
|
-
# ],
|
223
|
-
# }
|
224
|
-
|
225
|
-
# with open(self.saved_file_path_name, "w") as file:
|
226
|
-
# json.dump(state, file)
|
227
|
-
|
228
|
-
# def load(self):
|
229
|
-
# """Loads the state of all agents."""
|
230
|
-
# with open(self.saved_file_path_name) as file:
|
231
|
-
# state = json.load(file)
|
232
|
-
# self._step = state["step"]
|
233
|
-
# self.results = state["results"]
|
234
|
-
# return state
|
235
|
-
|
236
|
-
# def __repr__(self):
|
237
|
-
# return (
|
238
|
-
# f"MultiAgentCollaboration(agents={self.agents},"
|
239
|
-
# f" selection_function={self.select_next_speaker},"
|
240
|
-
# f" max_loops={self.max_loops}, autosave={self.autosave},"
|
241
|
-
# f" saved_file_path_name={self.saved_file_path_name})"
|
242
|
-
# )
|