swarms 7.7.8__py3-none-any.whl → 7.8.0__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/__init__.py +0 -1
- swarms/agents/cort_agent.py +206 -0
- swarms/agents/react_agent.py +173 -0
- swarms/agents/self_agent_builder.py +40 -0
- swarms/communication/base_communication.py +290 -0
- swarms/communication/duckdb_wrap.py +369 -72
- swarms/communication/pulsar_struct.py +691 -0
- swarms/communication/redis_wrap.py +1362 -0
- swarms/communication/sqlite_wrap.py +547 -44
- swarms/prompts/agent_self_builder_prompt.py +103 -0
- swarms/prompts/safety_prompt.py +50 -0
- swarms/schemas/__init__.py +6 -1
- swarms/schemas/agent_class_schema.py +91 -0
- swarms/schemas/agent_mcp_errors.py +18 -0
- swarms/schemas/agent_tool_schema.py +13 -0
- swarms/schemas/llm_agent_schema.py +92 -0
- swarms/schemas/mcp_schemas.py +43 -0
- swarms/structs/__init__.py +4 -0
- swarms/structs/agent.py +315 -267
- swarms/structs/aop.py +3 -1
- swarms/structs/batch_agent_execution.py +64 -0
- swarms/structs/conversation.py +261 -57
- swarms/structs/council_judge.py +542 -0
- swarms/structs/deep_research_swarm.py +19 -22
- swarms/structs/long_agent.py +424 -0
- swarms/structs/ma_utils.py +11 -8
- swarms/structs/malt.py +30 -28
- swarms/structs/multi_model_gpu_manager.py +1 -1
- swarms/structs/output_types.py +1 -1
- swarms/structs/swarm_router.py +70 -15
- swarms/tools/__init__.py +12 -0
- swarms/tools/base_tool.py +2840 -264
- swarms/tools/create_agent_tool.py +104 -0
- swarms/tools/mcp_client_call.py +504 -0
- swarms/tools/py_func_to_openai_func_str.py +45 -7
- swarms/tools/pydantic_to_json.py +10 -27
- swarms/utils/audio_processing.py +343 -0
- swarms/utils/history_output_formatter.py +5 -5
- swarms/utils/index.py +226 -0
- swarms/utils/litellm_wrapper.py +65 -67
- swarms/utils/try_except_wrapper.py +2 -2
- swarms/utils/xml_utils.py +42 -0
- {swarms-7.7.8.dist-info → swarms-7.8.0.dist-info}/METADATA +5 -4
- {swarms-7.7.8.dist-info → swarms-7.8.0.dist-info}/RECORD +47 -30
- {swarms-7.7.8.dist-info → swarms-7.8.0.dist-info}/WHEEL +1 -1
- swarms/client/__init__.py +0 -15
- swarms/client/main.py +0 -407
- swarms/tools/mcp_client.py +0 -246
- swarms/tools/mcp_integration.py +0 -340
- {swarms-7.7.8.dist-info → swarms-7.8.0.dist-info}/LICENSE +0 -0
- {swarms-7.7.8.dist-info → swarms-7.8.0.dist-info}/entry_points.txt +0 -0
@@ -1,17 +1,20 @@
|
|
1
|
-
swarms/__init__.py,sha256=
|
1
|
+
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
5
|
swarms/agents/ape_agent.py,sha256=1kz_65LJgjLlY1yv2WLBeVMs7sP9BgEVWk0w1f67YLc,1563
|
6
6
|
swarms/agents/auto_generate_swarm_config.py,sha256=7eJ873xS7PJmyreMaa5Uub8qFu-qIinuyMuogB2Ehjc,8474
|
7
7
|
swarms/agents/consistency_agent.py,sha256=41h0yvnjzmKsE8-q4UsN0ckHP7WWmB5E_z64ec9QaJM,7414
|
8
|
+
swarms/agents/cort_agent.py,sha256=cTorrAcdI46Zvf4RfTouVl4J2vdPSur5CHDWTTMgujU,8002
|
8
9
|
swarms/agents/create_agents_from_yaml.py,sha256=PgFIpuYZehxEl79BAK6TolSZwydDQzvGMAKhLsHuBbc,13008
|
9
10
|
swarms/agents/flexion_agent.py,sha256=Agjq1rvTzboE8lT26-mcjp0tKQEjlUj_eVYsFjLIvN0,21468
|
10
11
|
swarms/agents/gkp_agent.py,sha256=5Jms3zHQ2qwJ6-PHDh9X-cFtAlH4dSUoDgRqN-xZzog,21067
|
11
12
|
swarms/agents/i_agent.py,sha256=_eKUcgPfiVqQpF5Q-Sv1tT-JZxIeNl9Fp7OrnjVUtz8,12276
|
12
13
|
swarms/agents/openai_assistant.py,sha256=mTSEtj26J0mc5pCeWrmMY0EXzTRYQfyfw_BtOqtcCHc,11044
|
14
|
+
swarms/agents/react_agent.py,sha256=yM8lQoRsqJZicqtmgBrC7RHv0aKEb5oZHh4q5aAA_xs,5804
|
13
15
|
swarms/agents/reasoning_agents.py,sha256=tF7K710lj-VZQVc2VjqxMWGLNGMsEWRarXcJnXz1wkc,5741
|
14
16
|
swarms/agents/reasoning_duo.py,sha256=s9SnXoproQaBrShLtiruGJituy8sJlZJATc5Vy_FdwI,3875
|
17
|
+
swarms/agents/self_agent_builder.py,sha256=bX7xSwak6HiyK901VdeE8OlT4yqE0n7jyHcWJrkMeew,1104
|
15
18
|
swarms/agents/tool_agent.py,sha256=G7rhBACsHsGUMT4H9eF5aY7e3Gx-5jOmJkhCF1jm9mU,5087
|
16
19
|
swarms/artifacts/__init__.py,sha256=M111xTw7IVVt8gLDwW7Kau5n1YdwkL3vbCJPVeEWktI,83
|
17
20
|
swarms/artifacts/main_artifact.py,sha256=bu2TcsTR81ttJEjVJ3NzT7D4x7uuM57okC92QuigV9I,11139
|
@@ -19,11 +22,12 @@ swarms/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
22
|
swarms/cli/create_agent.py,sha256=o2V6EDQN477MxUOm0wShlr4uNyPpPzqpJhGM5tiuWUU,1128
|
20
23
|
swarms/cli/main.py,sha256=T9YsCrNIzvbQA8h5qlke-TbRP498Wu6R_KkAxRiabvs,15319
|
21
24
|
swarms/cli/onboarding_process.py,sha256=3-2LKoLhjnaPbX9iiasqXPZZpqmwm-ZrXawH88M4BIU,6940
|
22
|
-
swarms/client/__init__.py,sha256=VASeCEYoZskTU3NOw5tQ22uc2_7gyK0oLsxG_WB20ys,268
|
23
|
-
swarms/client/main.py,sha256=f-RpvfKfRK2AaapkyPN2ihXJvIGN4JWB_A7pJu4WyiU,13735
|
24
25
|
swarms/communication/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
25
|
-
swarms/communication/
|
26
|
-
swarms/communication/
|
26
|
+
swarms/communication/base_communication.py,sha256=0aQavvEQv24MHvulZ2mGVmQ9hkqROSIW608wfo8-P9s,8559
|
27
|
+
swarms/communication/duckdb_wrap.py,sha256=cdVG6-V5R4xV_503yFO--QtIfkx35hkzppK8MTJEeNY,44549
|
28
|
+
swarms/communication/pulsar_struct.py,sha256=hsP-CA88KB578_3Gc4kOF3z5DILckZxjlcz7xSzjxXY,23758
|
29
|
+
swarms/communication/redis_wrap.py,sha256=f-NvlnJQ1PhUpZLDamNrvQ4rl0ykof8Di5H8ZQ_IFbA,47331
|
30
|
+
swarms/communication/sqlite_wrap.py,sha256=PD7p5bdTjK6a7yqdlAJtgduO9WdAb_wJpQlCSH6gbG0,43604
|
27
31
|
swarms/prompts/__init__.py,sha256=ZFcghAs4b0Rsjcc_DIFssiztZub5tJ66rxmJD2_tXpQ,747
|
28
32
|
swarms/prompts/accountant_swarm_prompts.py,sha256=swceN1B0fZCOedd3-y3gjNOHDmR-3H5YK17ytp7tTDM,11320
|
29
33
|
swarms/prompts/ag_prompt.py,sha256=mMeqC84SMNrCjQcBeejroSXLuF_wWrVRebHU1MrEQko,4577
|
@@ -31,6 +35,7 @@ swarms/prompts/aga.py,sha256=4rRG7r9LF9JBrGOLN4Hy_6cSe0z5YOeKFbGnOmRfFJ0,9156
|
|
31
35
|
swarms/prompts/agent_judge_prompt.py,sha256=-2q5mWLRyO7pj7j512ZNYRm-uEZttPgDGaxZo3oM_QQ,2235
|
32
36
|
swarms/prompts/agent_prompt.py,sha256=6SXkMWcFIIAY02N9P6kMdzo4wtPwzg1Bl9R2qsIdicM,2705
|
33
37
|
swarms/prompts/agent_prompts.py,sha256=63ZqAO1jfH3TKtl9ibLLagSG5kAPlbq4xtCGgGEuuoA,6886
|
38
|
+
swarms/prompts/agent_self_builder_prompt.py,sha256=cpO6VgtKaZAZ0aD3spzkzsMgdwEKo1_UALfLgczkFdU,6167
|
34
39
|
swarms/prompts/agent_system_prompts.py,sha256=3Ae6bSZjyRtV1nlkHkm8pYgWoZjzzVR1_amaNQ-Z9Do,7796
|
35
40
|
swarms/prompts/ai_research_team.py,sha256=6j8eqKih4PKSwYoS1BSBSEhZEGPiZCbTVX6aBUVNRIw,5233
|
36
41
|
swarms/prompts/aot_prompt.py,sha256=c1CBRixF2ucKZ0erwAjSOTSNHo_qO2jwUR-D3dxpfXw,1148
|
@@ -68,6 +73,7 @@ swarms/prompts/react.py,sha256=nPuaIgKD2xV41y0PR06mrkC82GnWk4mw0apkrcYS_cY,2960
|
|
68
73
|
swarms/prompts/react_base_prompt.py,sha256=vN82wlxwj7c5PzIXMDcXg17950D2UZDDLaaRhGiAbQA,1928
|
69
74
|
swarms/prompts/reasoning_prompt.py,sha256=tnuJWK9VHer0IvgwjUXCM5ixMn-yfozQL0KgKQKciu4,1113
|
70
75
|
swarms/prompts/refiner_agent_prompt.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
76
|
+
swarms/prompts/safety_prompt.py,sha256=PsBr_dG1YoCQQCCWmwI2qQA8q8U84mNfn2L5tkM0BX4,2913
|
71
77
|
swarms/prompts/sales.py,sha256=tIr46slbRA8KxoOERE83DX10cGvwafzocpR00KcG_tM,5126
|
72
78
|
swarms/prompts/sales_prompts.py,sha256=GxBdYT3Nxz2ouD-d1dDVZavFbidpJwi6z8QqTv-BX8s,5013
|
73
79
|
swarms/prompts/security_team.py,sha256=mg5PP-IBD6Bb81l8VxJQMZIZ_PEAN7KMfHhnMy6qtKY,2679
|
@@ -83,34 +89,42 @@ swarms/prompts/urban_planning.py,sha256=z483ehEuZwKuddbxS2s7fteDlb_iQ_Cj8DMCM_QC
|
|
83
89
|
swarms/prompts/visual_cot.py,sha256=PKePf57hu5sjaG5IvMFAxPzbLuPYrmnWEQG1MOq3TIg,3675
|
84
90
|
swarms/prompts/worker_prompt.py,sha256=f6qPN24vEciGRTHyYjNDguhzCFPZqa2u05rEHIPcJto,5554
|
85
91
|
swarms/prompts/xray_swarm_prompt.py,sha256=AfV_y8GVuEodznOGQ9Q8QlInoLE5Px3Nl9GS_EpsDxg,2349
|
86
|
-
swarms/schemas/__init__.py,sha256=
|
92
|
+
swarms/schemas/__init__.py,sha256=G2PKMJONzT3x6_edNqNjTgCgpTyul4UKhpC5cSe8Zjw,247
|
93
|
+
swarms/schemas/agent_class_schema.py,sha256=SG04rPZEHE4XWwC402qvfRMRJpyhQ0AvsHF-_B-e2Cg,4581
|
94
|
+
swarms/schemas/agent_mcp_errors.py,sha256=2BDsZAt9Pgmfh_D5DKY5vc9psw4Wl0FevL60yfiQvKk,266
|
87
95
|
swarms/schemas/agent_step_schemas.py,sha256=a14gb58vR0xOwB_fwSJQbN6yb9HddEaT30E6hUrzEQA,2573
|
96
|
+
swarms/schemas/agent_tool_schema.py,sha256=XdaKie6R0WhNXlnEl9f5T3hHmMedFbVwG17fdHP_U3E,385
|
88
97
|
swarms/schemas/base_schemas.py,sha256=UvBLVWg2qRen4tK5GJz50v42SiX95EQ5qK7hfyAHTEU,3267
|
89
|
-
swarms/
|
90
|
-
swarms/
|
98
|
+
swarms/schemas/llm_agent_schema.py,sha256=om3tPSjwbkIj2Hr38mKMLJvWs0E2BaE1jw2kzzd0Www,3020
|
99
|
+
swarms/schemas/mcp_schemas.py,sha256=XZJ4HyiY_cv8Gvj-53ddjzXuqT9hBU2f0cHbhIKs_jY,1330
|
100
|
+
swarms/structs/__init__.py,sha256=VEHVLHULQDqpCKGhBQ-oxiQAwP_9dI9K1mRF8WSYRvg,4231
|
101
|
+
swarms/structs/agent.py,sha256=MsPTIbIeOCa43eU6hIIp1pd8VSm07SjWB0he19msoyQ,100435
|
91
102
|
swarms/structs/agent_builder.py,sha256=tYNpfO4_8cgfMHfgA5DAOWffHnt70p6CLt59esqfVCY,12133
|
92
103
|
swarms/structs/agent_registry.py,sha256=il507cO1NF-d4ChyANVLuWrN8bXsEAi8_7bLJ_sTU6A,12112
|
93
104
|
swarms/structs/agent_roles.py,sha256=8XEw6RjOOZelaZaWt4gXaYQm5WMLEhSO7W6Z8sQjmFg,582
|
94
105
|
swarms/structs/agent_router.py,sha256=YZw5AaK2yTvxkOA7ouED_4MoYgn0XZggvo1wrglp-4E,13017
|
95
|
-
swarms/structs/aop.py,sha256
|
106
|
+
swarms/structs/aop.py,sha256=VQS1oDtg4cXVBxRaxMSYSM5X4nzVFy7u7mLmiOqDWZo,17408
|
96
107
|
swarms/structs/auto_swarm_builder.py,sha256=79hd-3GpEyCGgS6tj4FvGFyM8768McQZJQXbGGj9XMk,12973
|
97
108
|
swarms/structs/base_structure.py,sha256=GDu4QJQQmhU7IyuFJHIh9UVThACCva-L7uoMbVD9l4s,15901
|
98
109
|
swarms/structs/base_swarm.py,sha256=LSGJDPJdyUCcK6698mNtjxoC1OU3s_J2NxC2k_ccGUs,23779
|
99
110
|
swarms/structs/base_workflow.py,sha256=DTfFwX3AdFYxACDYwUDqhsbcDZnITlg5TeEYyxmJBCc,11414
|
111
|
+
swarms/structs/batch_agent_execution.py,sha256=d85DzeCq4uTbbPqLhAXFqFx_cxXUS5yRnJ1-gJkwU5w,1871
|
100
112
|
swarms/structs/concat.py,sha256=utezSxNyh1mIwXgdf8-dJ803NDPyEy79WE8zJHuooGk,732
|
101
113
|
swarms/structs/concurrent_workflow.py,sha256=OqXI-X-9a0hG2a7aLzobwd7CVF2ez0rgLj3ZHqri5bg,12952
|
102
|
-
swarms/structs/conversation.py,sha256=
|
114
|
+
swarms/structs/conversation.py,sha256=88FgnM5tHOjC_F0TGRT04gkiPnE3tiept4ipnCO4iw8,27501
|
115
|
+
swarms/structs/council_judge.py,sha256=siYDKiHMvFmShUTXxdo4R6vXiQhKt7bEBI205oC3kU4,19639
|
103
116
|
swarms/structs/csv_to_agent.py,sha256=ug9JqQFPguXeU9JQpSUXuVtOpHYdJhlpKJUJBovo694,9443
|
104
117
|
swarms/structs/de_hallucination_swarm.py,sha256=9cC0rSSXGwYu6SRDwpeMbCcQ40C1WI1RE9SNapKRLOQ,10309
|
105
|
-
swarms/structs/deep_research_swarm.py,sha256=
|
118
|
+
swarms/structs/deep_research_swarm.py,sha256=3f8T_t-gIg5wbfU2JrMmZ9Ob4Qn153zXdzt5ZpydmXk,16777
|
106
119
|
swarms/structs/dynamic_conversational_swarm.py,sha256=n_d1jDCzBwiGb0QjJpW_MlXxqEkhGEhC1ttaebH7f3Q,8098
|
107
120
|
swarms/structs/graph_workflow.py,sha256=TAaUG_J3898hhghPOp0WEAV3Zf0in6s48ZSVbSTX-vQ,8629
|
108
121
|
swarms/structs/groupchat.py,sha256=jjH0BqU9Nrd_3jl9QzrcvbSce527SFpUaepawaRiw2o,15391
|
109
122
|
swarms/structs/hiearchical_swarm.py,sha256=2x3InS4HJg4T9Y195l_ANTGu6DYcllqCdJcR3v5Xuro,33402
|
110
123
|
swarms/structs/hybrid_hiearchical_peer_swarm.py,sha256=D1iBtNNee_mxPoOWS5WGTqcci5FQKtt38mW-J42GvfM,9494
|
111
|
-
swarms/structs/
|
124
|
+
swarms/structs/long_agent.py,sha256=KFjE2uUI8ONTkeJO43Sh3y5-Ec0kga28BECGklic-S4,15049
|
125
|
+
swarms/structs/ma_utils.py,sha256=s8uTCplQtiFvxyqyTTTUCnJDMwNLJEuxbdGZyOURjLg,3244
|
112
126
|
swarms/structs/majority_voting.py,sha256=F_t_MOC3YCRyMw5N6qKdFThpaXZxwixRw592Ku5Uhto,10122
|
113
|
-
swarms/structs/malt.py,sha256=
|
127
|
+
swarms/structs/malt.py,sha256=uLofKBWHkP3uNhyCkkgEyE4Z7qnOHTtcg-OTiR19x_Y,19572
|
114
128
|
swarms/structs/matrix_swarm.py,sha256=qHuhOYrTyOv6ujHMe8PrQT-h-WmaCPCfX4ghv5L8UFI,9765
|
115
129
|
swarms/structs/meme_agent_persona_generator.py,sha256=b3kKlumhsV4KV88-GS3CUnGO1UfKTU3fT8SAMj0ZlwQ,10645
|
116
130
|
swarms/structs/mixture_of_agents.py,sha256=Ix2YTdrzISPQJLrQ5vrZtYOpZwIYDx0vUaNmvBwDDVM,7762
|
@@ -118,9 +132,9 @@ swarms/structs/model_router.py,sha256=V5pZHYlxSmCvAA2Gsns7LaCz8dXtRi7pCvb-oLGHYI
|
|
118
132
|
swarms/structs/multi_agent_collab.py,sha256=odh2NQRR23LidsphCxUfAke369lDdgL__w3Xovu9jkA,7731
|
119
133
|
swarms/structs/multi_agent_exec.py,sha256=Gxwr9mHADX3n29pdxor-dQDnKPSNdnicpCxBLmPwnLg,14344
|
120
134
|
swarms/structs/multi_agent_router.py,sha256=21PfswEuxMHqlWDBCyritj9UuHTShYVQRaK0o23eia8,10999
|
121
|
-
swarms/structs/multi_model_gpu_manager.py,sha256=
|
135
|
+
swarms/structs/multi_model_gpu_manager.py,sha256=gHC6MmVia4etMD6RlpEdbqZtV7ng4f-6jVMH0Zrt8y4,47356
|
122
136
|
swarms/structs/omni_agent_types.py,sha256=RdKLfZ-lXDJrEa0aJT_Rfx9TypJQo8SISqKz4fnLkAk,230
|
123
|
-
swarms/structs/output_types.py,sha256=
|
137
|
+
swarms/structs/output_types.py,sha256=gbZfmogjcnx0jDWZecSX2yPuNXHkgWU-feHeQ1fuvmM,191
|
124
138
|
swarms/structs/rearrange.py,sha256=5u7HwTVVH414w9rhEQvLdltW1ACHjgwn-zS8-8JEXmA,22576
|
125
139
|
swarms/structs/round_robin.py,sha256=MGk623KiN9uSxTMG6MY_BIAkvEDh1RPwyl5Min7GLOU,7573
|
126
140
|
swarms/structs/safe_loading.py,sha256=gmYX8G9TsvAIp6OCvREBZt5mwSFc-p-t1rSnDBfhEmE,7124
|
@@ -132,7 +146,7 @@ swarms/structs/swarm_eval.py,sha256=148E2R2zaCmt_LZYx15nmdFjybXHiQ2CZbl6pk77jNs,
|
|
132
146
|
swarms/structs/swarm_id_generator.py,sha256=Wly7AtGM9e6VgzhYmfg8_gSOdxAdsOvWHJFK81cpQNQ,68
|
133
147
|
swarms/structs/swarm_matcher.py,sha256=E2KwHHEJxmW-UfTeMPWZ6VCmYdQ_I9_fwrfJbxD02GY,23322
|
134
148
|
swarms/structs/swarm_registry.py,sha256=P0XRrqp1qBNyt0BycqPQljUzKv9jClaQMhtaBMinhYg,5578
|
135
|
-
swarms/structs/swarm_router.py,sha256=
|
149
|
+
swarms/structs/swarm_router.py,sha256=oj5QumyxutVawthcTFUsY8DcHbn3iWOxAi7xpkoDRQg,30457
|
136
150
|
swarms/structs/swarming_architectures.py,sha256=q2XrY2lOqFhVckA8oin65Dz1VPUe-lfbEJHlP1Z8aTE,28278
|
137
151
|
swarms/structs/tree_swarm.py,sha256=AnIxrt0KhWxAQN8uGjfCcOq-XCmsuTJiH8Ex4mXy8V8,12500
|
138
152
|
swarms/structs/utils.py,sha256=Mo6wHQYOB8baWZUKnAJN5Dsgubpo81umNwJIEDitb2A,1873
|
@@ -140,27 +154,28 @@ swarms/structs/various_alt_swarms.py,sha256=qdBuOF31UjatlKRu-9bxwyRQzIjohRhTv_63
|
|
140
154
|
swarms/telemetry/__init__.py,sha256=yibtkHEbQRPUv6ir1FhDHlAO_3nwKJPQH4LjzBC2AuQ,661
|
141
155
|
swarms/telemetry/bootup.py,sha256=0leCNCy5rhzL19EsOsqHWSDI85KVcWO6_5hLDS0h4sY,1155
|
142
156
|
swarms/telemetry/main.py,sha256=8FxivorvclSvhgfU03cHFktaRgRNV1UXCMi0VV8-U60,11248
|
143
|
-
swarms/tools/__init__.py,sha256=
|
144
|
-
swarms/tools/base_tool.py,sha256=
|
157
|
+
swarms/tools/__init__.py,sha256=tyGQpcfrosMx06fdV9h_8_9WB-1vfT-aAjZufiTXyPQ,1838
|
158
|
+
swarms/tools/base_tool.py,sha256=LMGfH2o9nrCdsuVxI2mfxtkIMcXTs2oO_jAF1ebU-YY,107065
|
145
159
|
swarms/tools/cohere_func_call_schema.py,sha256=XJ6_yBMXCrV9KjN7v9Bk1iFj69TRlGIWYKsUTA1oGiQ,600
|
160
|
+
swarms/tools/create_agent_tool.py,sha256=YsiBgrR9gkn2Jenu_mIFXOMJCWb_Hdw4gBYPQN5HEQk,3467
|
146
161
|
swarms/tools/func_calling_utils.py,sha256=PhHHZRHN-vRHA_h21ELRjXIhSRIrsT4UhU5-1Bhy-iU,3542
|
147
162
|
swarms/tools/func_to_str.py,sha256=J_E3ejEYxl_u7Te9xvHWGE83EW0-CRBRqafiXMUvto8,1129
|
148
163
|
swarms/tools/function_util.py,sha256=DAnAPO0Ik__TAqL7IJzFmkukHnhpsW_QtALl3yj837g,1158
|
149
164
|
swarms/tools/json_former.py,sha256=4ugLQ_EZpghhuhFsVKsy-ehin9K64pqVE2gLU7BTO_M,14376
|
150
165
|
swarms/tools/json_utils.py,sha256=WKMZjcJ0Vt6lgIjiTBenslcfjgRSLX4UWs4uDkKFMQI,1316
|
151
166
|
swarms/tools/logits_processor.py,sha256=NifZZ5w9yemWGJAJ5nHFrphtZVX1XlyesgvYZTxK1GM,2965
|
152
|
-
swarms/tools/
|
153
|
-
swarms/tools/mcp_integration.py,sha256=ZxVj5T6qBy9K9YTpXmDn2LiA4Q-Wj0TTuF3SnI_Jiu0,11725
|
167
|
+
swarms/tools/mcp_client_call.py,sha256=4iYDpMT_v0Kk_RTgL0bfQruxJJJuXNPmZQalHL1vm6c,15287
|
154
168
|
swarms/tools/openai_func_calling_schema_pydantic.py,sha256=6BAH9kuaVTvJIbjgSSJ5XvHhWvWszPxgarkfUuE5Ads,978
|
155
169
|
swarms/tools/openai_tool_creator_decorator.py,sha256=SYZjHnARjWvnH9cBdj7Kc_Yy1muvNxMT3RQz8KkA2SE,2578
|
156
|
-
swarms/tools/py_func_to_openai_func_str.py,sha256=
|
157
|
-
swarms/tools/pydantic_to_json.py,sha256
|
170
|
+
swarms/tools/py_func_to_openai_func_str.py,sha256=sjoNutRZ11-0kYFDalUTxZxQ0TEDyn5R8EXMdS4gsgw,17091
|
171
|
+
swarms/tools/pydantic_to_json.py,sha256=sd5uWwjSHsu7M8wCBrPv0uje05-K4xcfbvKQ_zOaww8,3399
|
158
172
|
swarms/tools/tool_parse_exec.py,sha256=FW5XzkuNEs2YrroybjKChbCzDvaCs7ypknSDpYhfkd4,8717
|
159
173
|
swarms/tools/tool_registry.py,sha256=ULZmIKBTx9XRCJRD9hwXfY3iQw9v94arw-VV6jcuftY,7992
|
160
174
|
swarms/tools/tool_schema_base_model.py,sha256=0biTGIoibsPPP3fOrkC6WvNU5vXaalyccVKC1fpO_eg,1409
|
161
175
|
swarms/tools/tool_utils.py,sha256=yXzzqG7Ytd8ybB8bsjNUNLaXIuIp9JbbpUKCiHxQqo8,2816
|
162
176
|
swarms/utils/__init__.py,sha256=9qKE_11pxom74j3qExSm6Z_LwR5lrpC5YG17v22eLlo,975
|
163
177
|
swarms/utils/any_to_str.py,sha256=Qi4N9ed6LYnCs2AeFYo1zwEfYhOKUesGVFUmVUz54KI,2936
|
178
|
+
swarms/utils/audio_processing.py,sha256=Y3KaWG9WJrgquWCeaty20HWPIXfeuPAhcJFzoSBIQjE,9893
|
164
179
|
swarms/utils/auto_download_check_packages.py,sha256=mqx3jCetfkTuxTdeGLx-gGMB1xWOU5vata8lTKXLatk,4580
|
165
180
|
swarms/utils/calculate_func_metrics.py,sha256=Nb5r7rWf809m5F7mWIYXZ0H_WeyGr78A2UZD2GHtJkM,5007
|
166
181
|
swarms/utils/data_to_text.py,sha256=1PUoWokylp7MOrGNk1cmO3cJlfskdAIiImGk9ECwsKU,3427
|
@@ -169,20 +184,22 @@ swarms/utils/file_processing.py,sha256=QjQCIPTcwicQlfy656BXBYpIzMR0s2343E7ftnok5
|
|
169
184
|
swarms/utils/formatter.py,sha256=e15FsyTIIkyRreMUApkkZCzJC1Sm67w5Zd6EQcUkMwA,4533
|
170
185
|
swarms/utils/function_caller_model.py,sha256=ZfgCMzOizNnuZipYLclTziECNHszH9p8RQcUq7VNr4Q,4156
|
171
186
|
swarms/utils/generate_keys.py,sha256=i0Ewm1LCTLaqp7qm7B7MgNolaI9IZyJcxNVRLUZklt4,1700
|
172
|
-
swarms/utils/history_output_formatter.py,sha256=
|
187
|
+
swarms/utils/history_output_formatter.py,sha256=d4J-TF63ENCjsQXU36MGR2pvx59y0qBFuBlOrJt_K8M,1487
|
188
|
+
swarms/utils/index.py,sha256=iYVlMiuSpBuKHF34uSrxDUuSYmS26bbYoAqyz_VIyvY,6902
|
173
189
|
swarms/utils/litellm_tokenizer.py,sha256=0AAj4NffBe2eHii_3_5SpQAhSiBbunJR8MzaBTIm7hg,484
|
174
|
-
swarms/utils/litellm_wrapper.py,sha256=
|
190
|
+
swarms/utils/litellm_wrapper.py,sha256=dZ9KCR_Rxlm3VZWWVfhpTb4Y6KM_xHipynueJUeU_Jc,15023
|
175
191
|
swarms/utils/loguru_logger.py,sha256=hIoSK3NHLpe7eAmjHRURrEYzNXYC2gbR7_Vv63Yaydk,685
|
176
192
|
swarms/utils/markdown_message.py,sha256=RThHNnMf6ZLTlYK4vKn3yuewChaxWAYAWb0Xm_pTyIU,652
|
177
193
|
swarms/utils/parse_code.py,sha256=XFOLymbdP3HzMZuqsj7pwUyisvUmTm0ev9iThR_ambI,1987
|
178
194
|
swarms/utils/pdf_to_text.py,sha256=nkySOS_sJ4Jf4RP5SoDpMB5WfjJ_GGc5z8gJfn2cxOM,1311
|
179
195
|
swarms/utils/str_to_dict.py,sha256=T3Jsdjz87WIlkSo7jAW6BB80sv0Ns49WT1qXlOrdEoE,874
|
180
|
-
swarms/utils/try_except_wrapper.py,sha256=
|
196
|
+
swarms/utils/try_except_wrapper.py,sha256=uvDZDZJcH986EF0Ej6zZBLcqHJ58NHizPsAH5olrE7Q,3919
|
181
197
|
swarms/utils/visualizer.py,sha256=0ylohEk62MAS6iPRaDOV03m9qo2k5J56tWlKJk_46p4,16927
|
182
198
|
swarms/utils/vllm_wrapper.py,sha256=OIGnU9Vf81vE_hul1FK-xEhChFK8fxqZX6-fhQeW22c,4987
|
183
199
|
swarms/utils/wrapper_clusterop.py,sha256=PMSCVM7ZT1vgj1D_MYAe835RR3SMLYxA-si2JS02yNQ,4220
|
184
|
-
swarms
|
185
|
-
swarms-7.
|
186
|
-
swarms-7.
|
187
|
-
swarms-7.
|
188
|
-
swarms-7.
|
200
|
+
swarms/utils/xml_utils.py,sha256=j8byUa56VT7V4e18pL8UBftLdyWKsUHbid1KDxnAWBo,1416
|
201
|
+
swarms-7.8.0.dist-info/LICENSE,sha256=jwRtEmTWjLrEsvFB6QFdYs2cEeZPRMdj-UMOFkPF8_0,11363
|
202
|
+
swarms-7.8.0.dist-info/METADATA,sha256=6Npfe5U1IoF9Rty5vbt4vp-17U5psURrMEIFPdqCDXw,94969
|
203
|
+
swarms-7.8.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
204
|
+
swarms-7.8.0.dist-info/entry_points.txt,sha256=2K0rTtfO1X1WaO-waJlXIKw5Voa_EpAL_yU0HXE2Jgc,47
|
205
|
+
swarms-7.8.0.dist-info/RECORD,,
|
swarms/client/__init__.py
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
from swarms.client.main import (
|
2
|
-
SwarmsAPIClient,
|
3
|
-
AgentInput,
|
4
|
-
SwarmRequest,
|
5
|
-
SwarmAPIError,
|
6
|
-
SwarmAuthenticationError,
|
7
|
-
)
|
8
|
-
|
9
|
-
__all__ = [
|
10
|
-
"SwarmsAPIClient",
|
11
|
-
"AgentInput",
|
12
|
-
"SwarmRequest",
|
13
|
-
"SwarmAPIError",
|
14
|
-
"SwarmAuthenticationError",
|
15
|
-
]
|
swarms/client/main.py
DELETED
@@ -1,407 +0,0 @@
|
|
1
|
-
import json
|
2
|
-
import os
|
3
|
-
from typing import List, Literal, Optional
|
4
|
-
|
5
|
-
import httpx
|
6
|
-
from swarms.utils.loguru_logger import initialize_logger
|
7
|
-
from pydantic import BaseModel, Field
|
8
|
-
from tenacity import retry, stop_after_attempt, wait_exponential
|
9
|
-
from swarms.structs.swarm_router import SwarmType
|
10
|
-
from typing import Any
|
11
|
-
|
12
|
-
logger = initialize_logger(log_folder="swarms_api")
|
13
|
-
|
14
|
-
|
15
|
-
class AgentInput(BaseModel):
|
16
|
-
agent_name: Optional[str] = Field(
|
17
|
-
None,
|
18
|
-
description="The name of the agent, limited to 100 characters.",
|
19
|
-
max_length=100,
|
20
|
-
)
|
21
|
-
description: Optional[str] = Field(
|
22
|
-
None,
|
23
|
-
description="A detailed description of the agent's purpose and capabilities, up to 500 characters.",
|
24
|
-
max_length=500,
|
25
|
-
)
|
26
|
-
system_prompt: Optional[str] = Field(
|
27
|
-
None,
|
28
|
-
description="The initial prompt or instructions given to the agent.",
|
29
|
-
)
|
30
|
-
model_name: Optional[str] = Field(
|
31
|
-
"gpt-4o",
|
32
|
-
description="The name of the model used by the agent. Model names can be configured like provider/model_name",
|
33
|
-
)
|
34
|
-
auto_generate_prompt: Optional[bool] = Field(
|
35
|
-
False,
|
36
|
-
description="Indicates whether the agent should automatically generate prompts.",
|
37
|
-
)
|
38
|
-
max_tokens: Optional[int] = Field(
|
39
|
-
8192,
|
40
|
-
description="The maximum number of tokens the agent can use in its responses.",
|
41
|
-
)
|
42
|
-
temperature: Optional[float] = Field(
|
43
|
-
0.5,
|
44
|
-
description="Controls the randomness of the agent's responses; higher values result in more random outputs.",
|
45
|
-
)
|
46
|
-
role: Optional[str] = Field(
|
47
|
-
"worker",
|
48
|
-
description="The role assigned to the agent, such as 'worker' or 'manager'.",
|
49
|
-
)
|
50
|
-
max_loops: Optional[int] = Field(
|
51
|
-
1,
|
52
|
-
description="The maximum number of iterations the agent is allowed to perform.",
|
53
|
-
)
|
54
|
-
dynamic_temperature_enabled: Optional[bool] = Field(
|
55
|
-
True,
|
56
|
-
description="Indicates whether the agent should use dynamic temperature.",
|
57
|
-
)
|
58
|
-
|
59
|
-
|
60
|
-
class SwarmRequest(BaseModel):
|
61
|
-
name: Optional[str] = Field(
|
62
|
-
"swarms-01",
|
63
|
-
description="The name of the swarm, limited to 100 characters.",
|
64
|
-
max_length=100,
|
65
|
-
)
|
66
|
-
description: Optional[str] = Field(
|
67
|
-
None,
|
68
|
-
description="A comprehensive description of the swarm's objectives and scope, up to 500 characters.",
|
69
|
-
max_length=500,
|
70
|
-
)
|
71
|
-
agents: Optional[List[AgentInput]] = Field(
|
72
|
-
None,
|
73
|
-
description="A list of agents that are part of the swarm.",
|
74
|
-
)
|
75
|
-
max_loops: Optional[int] = Field(
|
76
|
-
1,
|
77
|
-
description="The maximum number of iterations the swarm can execute.",
|
78
|
-
)
|
79
|
-
swarm_type: Optional[SwarmType] = Field(
|
80
|
-
None,
|
81
|
-
description="The type of swarm, defining its operational structure and behavior.",
|
82
|
-
)
|
83
|
-
rearrange_flow: Optional[str] = Field(
|
84
|
-
None,
|
85
|
-
description="The flow or sequence in which agents are rearranged during the swarm's operation.",
|
86
|
-
)
|
87
|
-
task: Optional[str] = Field(
|
88
|
-
None,
|
89
|
-
description="The specific task or objective the swarm is designed to accomplish.",
|
90
|
-
)
|
91
|
-
img: Optional[str] = Field(
|
92
|
-
None,
|
93
|
-
description="A URL to an image associated with the swarm, if applicable.",
|
94
|
-
)
|
95
|
-
return_history: Optional[bool] = Field(
|
96
|
-
True,
|
97
|
-
description="Determines whether the full history of the swarm's operations should be returned.",
|
98
|
-
)
|
99
|
-
rules: Optional[str] = Field(
|
100
|
-
None,
|
101
|
-
description="Any specific rules or guidelines that the swarm should follow.",
|
102
|
-
)
|
103
|
-
output_type: Optional[str] = Field(
|
104
|
-
"str",
|
105
|
-
description="The format in which the swarm's output should be returned, such as 'str', 'json', or 'dict'.",
|
106
|
-
)
|
107
|
-
|
108
|
-
|
109
|
-
# class SwarmResponse(BaseModel):
|
110
|
-
# swarm_id: str
|
111
|
-
# status: str
|
112
|
-
# result: Optional[str]
|
113
|
-
# error: Optional[str]
|
114
|
-
|
115
|
-
|
116
|
-
class HealthResponse(BaseModel):
|
117
|
-
status: str
|
118
|
-
version: str
|
119
|
-
|
120
|
-
|
121
|
-
class SwarmAPIError(Exception):
|
122
|
-
"""Base exception for Swarms API errors."""
|
123
|
-
|
124
|
-
pass
|
125
|
-
|
126
|
-
|
127
|
-
class SwarmAuthenticationError(SwarmAPIError):
|
128
|
-
"""Raised when authentication fails."""
|
129
|
-
|
130
|
-
pass
|
131
|
-
|
132
|
-
|
133
|
-
class SwarmValidationError(SwarmAPIError):
|
134
|
-
"""Raised when request validation fails."""
|
135
|
-
|
136
|
-
pass
|
137
|
-
|
138
|
-
|
139
|
-
class SwarmsAPIClient:
|
140
|
-
"""Production-grade client for the Swarms API."""
|
141
|
-
|
142
|
-
def __init__(
|
143
|
-
self,
|
144
|
-
api_key: Optional[str] = None,
|
145
|
-
base_url: str = "https://api.swarms.world",
|
146
|
-
timeout: int = 30,
|
147
|
-
max_retries: int = 3,
|
148
|
-
format_type: Literal["pydantic", "json", "dict"] = "pydantic",
|
149
|
-
):
|
150
|
-
"""Initialize the Swarms API client.
|
151
|
-
|
152
|
-
Args:
|
153
|
-
api_key: API key for authentication. If not provided, looks for SWARMS_API_KEY env var
|
154
|
-
base_url: Base URL for the API
|
155
|
-
timeout: Request timeout in seconds
|
156
|
-
max_retries: Maximum number of retries for failed requests
|
157
|
-
format_type: Desired output format ('pydantic', 'json', 'dict')
|
158
|
-
"""
|
159
|
-
self.api_key = api_key or os.getenv("SWARMS_API_KEY")
|
160
|
-
|
161
|
-
if not self.api_key:
|
162
|
-
logger.error(
|
163
|
-
"API key not provided and SWARMS_API_KEY env var not found"
|
164
|
-
)
|
165
|
-
raise SwarmAuthenticationError(
|
166
|
-
"API key not provided and SWARMS_API_KEY env var not found"
|
167
|
-
)
|
168
|
-
|
169
|
-
self.base_url = base_url.rstrip("/")
|
170
|
-
self.timeout = timeout
|
171
|
-
self.max_retries = max_retries
|
172
|
-
self.format_type = format_type
|
173
|
-
# Setup HTTP client
|
174
|
-
self.client = httpx.Client(
|
175
|
-
timeout=timeout,
|
176
|
-
headers={
|
177
|
-
"x-api-key": self.api_key,
|
178
|
-
"Content-Type": "application/json",
|
179
|
-
},
|
180
|
-
)
|
181
|
-
logger.info(
|
182
|
-
"SwarmsAPIClient initialized with base_url: {}",
|
183
|
-
self.base_url,
|
184
|
-
)
|
185
|
-
|
186
|
-
@retry(
|
187
|
-
stop=stop_after_attempt(3),
|
188
|
-
wait=wait_exponential(multiplier=1, min=4, max=10),
|
189
|
-
reraise=True,
|
190
|
-
)
|
191
|
-
async def health_check(self) -> HealthResponse:
|
192
|
-
"""Check the API health status.
|
193
|
-
|
194
|
-
Args:
|
195
|
-
output_format: Desired output format ('pydantic', 'json', 'dict')
|
196
|
-
|
197
|
-
Returns:
|
198
|
-
HealthResponse object or formatted output
|
199
|
-
"""
|
200
|
-
logger.info("Performing health check")
|
201
|
-
try:
|
202
|
-
response = self.client.get(f"{self.base_url}/health")
|
203
|
-
response.raise_for_status()
|
204
|
-
health_response = HealthResponse(**response.json())
|
205
|
-
logger.info("Health check successful")
|
206
|
-
return self.format_output(
|
207
|
-
health_response, self.format_type
|
208
|
-
)
|
209
|
-
except httpx.HTTPError as e:
|
210
|
-
logger.error("Health check failed: {}", str(e))
|
211
|
-
raise SwarmAPIError(f"Health check failed: {str(e)}")
|
212
|
-
|
213
|
-
@retry(
|
214
|
-
stop=stop_after_attempt(3),
|
215
|
-
wait=wait_exponential(multiplier=1, min=4, max=10),
|
216
|
-
reraise=True,
|
217
|
-
)
|
218
|
-
async def arun(self, swarm_request: SwarmRequest) -> Any:
|
219
|
-
"""Create and run a new swarm.
|
220
|
-
|
221
|
-
Args:
|
222
|
-
swarm_request: SwarmRequest object containing the swarm configuration
|
223
|
-
output_format: Desired output format ('pydantic', 'json', 'dict')
|
224
|
-
|
225
|
-
Returns:
|
226
|
-
SwarmResponse object or formatted output
|
227
|
-
"""
|
228
|
-
logger.info(
|
229
|
-
"Creating and running a new swarm with request: {}",
|
230
|
-
swarm_request,
|
231
|
-
)
|
232
|
-
try:
|
233
|
-
response = self.client.post(
|
234
|
-
f"{self.base_url}/v1/swarm/completions",
|
235
|
-
json=swarm_request.model_dump(),
|
236
|
-
)
|
237
|
-
response.raise_for_status()
|
238
|
-
logger.info("Swarm creation and run successful")
|
239
|
-
return self.format_output(
|
240
|
-
response.json(), self.format_type
|
241
|
-
)
|
242
|
-
except httpx.HTTPStatusError as e:
|
243
|
-
if e.response.status_code == 401:
|
244
|
-
logger.error("Invalid API key")
|
245
|
-
raise SwarmAuthenticationError("Invalid API key")
|
246
|
-
elif e.response.status_code == 422:
|
247
|
-
logger.error("Invalid request parameters")
|
248
|
-
raise SwarmValidationError(
|
249
|
-
"Invalid request parameters"
|
250
|
-
)
|
251
|
-
logger.error("Swarm creation failed: {}", str(e))
|
252
|
-
raise SwarmAPIError(f"Swarm creation failed: {str(e)}")
|
253
|
-
except Exception as e:
|
254
|
-
logger.error(
|
255
|
-
"Unexpected error during swarm creation: {}", str(e)
|
256
|
-
)
|
257
|
-
raise
|
258
|
-
|
259
|
-
@retry(
|
260
|
-
stop=stop_after_attempt(3),
|
261
|
-
wait=wait_exponential(multiplier=1, min=4, max=10),
|
262
|
-
reraise=True,
|
263
|
-
)
|
264
|
-
def run(self, swarm_request: SwarmRequest) -> Any:
|
265
|
-
"""Create and run a new swarm.
|
266
|
-
|
267
|
-
Args:
|
268
|
-
swarm_request: SwarmRequest object containing the swarm configuration
|
269
|
-
output_format: Desired output format ('pydantic', 'json', 'dict')
|
270
|
-
|
271
|
-
Returns:
|
272
|
-
SwarmResponse object or formatted output
|
273
|
-
"""
|
274
|
-
logger.info(
|
275
|
-
"Creating and running a new swarm with request: {}",
|
276
|
-
swarm_request,
|
277
|
-
)
|
278
|
-
try:
|
279
|
-
response = self.client.post(
|
280
|
-
f"{self.base_url}/v1/swarm/completions",
|
281
|
-
json=swarm_request.model_dump(),
|
282
|
-
)
|
283
|
-
print(response.json())
|
284
|
-
logger.info("Swarm creation and run successful")
|
285
|
-
return response.json()
|
286
|
-
except httpx.HTTPStatusError as e:
|
287
|
-
if e.response.status_code == 401:
|
288
|
-
logger.error("Invalid API key")
|
289
|
-
raise SwarmAuthenticationError("Invalid API key")
|
290
|
-
elif e.response.status_code == 422:
|
291
|
-
logger.error("Invalid request parameters")
|
292
|
-
raise SwarmValidationError(
|
293
|
-
"Invalid request parameters"
|
294
|
-
)
|
295
|
-
logger.error("Swarm creation failed: {}", str(e))
|
296
|
-
raise SwarmAPIError(f"Swarm creation failed: {str(e)}")
|
297
|
-
except Exception as e:
|
298
|
-
logger.error(
|
299
|
-
"Unexpected error during swarm creation: {}", str(e)
|
300
|
-
)
|
301
|
-
raise
|
302
|
-
|
303
|
-
@retry(
|
304
|
-
stop=stop_after_attempt(3),
|
305
|
-
wait=wait_exponential(multiplier=1, min=4, max=10),
|
306
|
-
reraise=True,
|
307
|
-
)
|
308
|
-
async def run_batch(
|
309
|
-
self, swarm_requests: List[SwarmRequest]
|
310
|
-
) -> List[Any]:
|
311
|
-
"""Create and run multiple swarms in batch.
|
312
|
-
|
313
|
-
Args:
|
314
|
-
swarm_requests: List of SwarmRequest objects
|
315
|
-
output_format: Desired output format ('pydantic', 'json', 'dict')
|
316
|
-
|
317
|
-
Returns:
|
318
|
-
List of SwarmResponse objects or formatted outputs
|
319
|
-
"""
|
320
|
-
logger.info(
|
321
|
-
"Creating and running batch swarms with requests: {}",
|
322
|
-
swarm_requests,
|
323
|
-
)
|
324
|
-
try:
|
325
|
-
response = self.client.post(
|
326
|
-
f"{self.base_url}/v1/swarm/batch/completions",
|
327
|
-
json=[req.model_dump() for req in swarm_requests],
|
328
|
-
)
|
329
|
-
response.raise_for_status()
|
330
|
-
logger.info("Batch swarm creation and run successful")
|
331
|
-
return [
|
332
|
-
self.format_output(resp, self.format_type)
|
333
|
-
for resp in response.json()
|
334
|
-
]
|
335
|
-
except httpx.HTTPStatusError as e:
|
336
|
-
if e.response.status_code == 401:
|
337
|
-
logger.error("Invalid API key")
|
338
|
-
raise SwarmAuthenticationError("Invalid API key")
|
339
|
-
elif e.response.status_code == 422:
|
340
|
-
logger.error("Invalid request parameters")
|
341
|
-
raise SwarmValidationError(
|
342
|
-
"Invalid request parameters"
|
343
|
-
)
|
344
|
-
logger.error("Batch swarm creation failed: {}", str(e))
|
345
|
-
raise SwarmAPIError(
|
346
|
-
f"Batch swarm creation failed: {str(e)}"
|
347
|
-
)
|
348
|
-
except Exception as e:
|
349
|
-
logger.error(
|
350
|
-
"Unexpected error during batch swarm creation: {}",
|
351
|
-
str(e),
|
352
|
-
)
|
353
|
-
raise
|
354
|
-
|
355
|
-
def get_logs(self):
|
356
|
-
logger.info("Retrieving logs")
|
357
|
-
try:
|
358
|
-
response = self.client.get(
|
359
|
-
f"{self.base_url}/v1/swarm/logs"
|
360
|
-
)
|
361
|
-
response.raise_for_status()
|
362
|
-
logs = response.json()
|
363
|
-
logger.info("Logs retrieved successfully")
|
364
|
-
return self.format_output(logs, self.format_type)
|
365
|
-
except httpx.HTTPError as e:
|
366
|
-
logger.error("Failed to retrieve logs: {}", str(e))
|
367
|
-
raise SwarmAPIError(f"Failed to retrieve logs: {str(e)}")
|
368
|
-
|
369
|
-
def format_output(self, data, output_format: str):
|
370
|
-
"""Format the output based on the specified format.
|
371
|
-
|
372
|
-
Args:
|
373
|
-
data: The data to format
|
374
|
-
output_format: The desired output format ('pydantic', 'json', 'dict')
|
375
|
-
|
376
|
-
Returns:
|
377
|
-
Formatted data
|
378
|
-
"""
|
379
|
-
logger.info(
|
380
|
-
"Formatting output with format: {}", output_format
|
381
|
-
)
|
382
|
-
if output_format == "json":
|
383
|
-
return (
|
384
|
-
data.model_dump_json(indent=4)
|
385
|
-
if isinstance(data, BaseModel)
|
386
|
-
else json.dumps(data)
|
387
|
-
)
|
388
|
-
elif output_format == "dict":
|
389
|
-
return (
|
390
|
-
data.model_dump()
|
391
|
-
if isinstance(data, BaseModel)
|
392
|
-
else data
|
393
|
-
)
|
394
|
-
return data # Default to returning the pydantic model
|
395
|
-
|
396
|
-
def close(self):
|
397
|
-
"""Close the HTTP client."""
|
398
|
-
logger.info("Closing HTTP client")
|
399
|
-
self.client.close()
|
400
|
-
|
401
|
-
async def __aenter__(self):
|
402
|
-
logger.info("Entering async context")
|
403
|
-
return self
|
404
|
-
|
405
|
-
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
406
|
-
logger.info("Exiting async context")
|
407
|
-
self.close()
|