swarms 7.9.0__py3-none-any.whl → 7.9.1__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.
@@ -182,6 +182,7 @@ class SwarmRouter:
182
182
  list_all_agents: bool = False,
183
183
  conversation: Any = None,
184
184
  agents_config: Optional[Dict[Any, Any]] = None,
185
+ speaker_function: str = None,
185
186
  *args,
186
187
  **kwargs,
187
188
  ):
@@ -208,6 +209,7 @@ class SwarmRouter:
208
209
  self.list_all_agents = list_all_agents
209
210
  self.conversation = conversation
210
211
  self.agents_config = agents_config
212
+ self.speaker_function = speaker_function
211
213
 
212
214
  # Reliability check
213
215
  self.reliability_check()
@@ -358,6 +360,7 @@ class SwarmRouter:
358
360
  agents=self.agents,
359
361
  max_loops=self.max_loops,
360
362
  output_type=self.output_type,
363
+ speaker_function=self.speaker_function,
361
364
  )
362
365
 
363
366
  elif self.swarm_type == "DeepResearchSwarm":
@@ -463,14 +466,10 @@ class SwarmRouter:
463
466
 
464
467
  def update_system_prompt_for_agent_in_swarm(self):
465
468
  # Use list comprehension for faster iteration
466
- [
467
- setattr(
468
- agent,
469
- "system_prompt",
470
- agent.system_prompt + MULTI_AGENT_COLLAB_PROMPT_TWO,
471
- )
472
- for agent in self.agents
473
- ]
469
+ for agent in self.agents:
470
+ if agent.system_prompt is None:
471
+ agent.system_prompt = ""
472
+ agent.system_prompt += MULTI_AGENT_COLLAB_PROMPT_TWO
474
473
 
475
474
  def agent_config(self):
476
475
  agent_config = {}
@@ -151,6 +151,8 @@ class LiteLLM:
151
151
  retries # Add retries for better reliability
152
152
  )
153
153
 
154
+ litellm.drop_params = True
155
+
154
156
  def output_for_tools(self, response: any):
155
157
  if self.mcp_call is True:
156
158
  out = response.choices[0].message.tool_calls[0].function
@@ -0,0 +1,66 @@
1
+ import time
2
+ from typing import Any, Callable, Type, Union, Tuple
3
+ from loguru import logger
4
+
5
+
6
+ def retry_function(
7
+ func: Callable,
8
+ *args: Any,
9
+ max_retries: int = 3,
10
+ delay: float = 1.0,
11
+ backoff_factor: float = 2.0,
12
+ exceptions: Union[
13
+ Type[Exception], Tuple[Type[Exception], ...]
14
+ ] = Exception,
15
+ **kwargs: Any,
16
+ ) -> Any:
17
+ """
18
+ A function that retries another function if it raises specified exceptions.
19
+
20
+ Args:
21
+ func (Callable): The function to retry
22
+ *args: Positional arguments to pass to the function
23
+ max_retries (int): Maximum number of retries before giving up. Defaults to 3.
24
+ delay (float): Initial delay between retries in seconds. Defaults to 1.0.
25
+ backoff_factor (float): Multiplier applied to delay between retries. Defaults to 2.0.
26
+ exceptions (Exception or tuple): Exception(s) that trigger a retry. Defaults to Exception.
27
+ **kwargs: Keyword arguments to pass to the function
28
+
29
+ Returns:
30
+ Any: The return value of the function if successful
31
+
32
+ Example:
33
+ def fetch_data(url: str) -> dict:
34
+ return requests.get(url).json()
35
+
36
+ # Retry the fetch_data function
37
+ result = retry_function(
38
+ fetch_data,
39
+ "https://api.example.com",
40
+ max_retries=3,
41
+ exceptions=(ConnectionError, TimeoutError)
42
+ )
43
+ """
44
+ retries = 0
45
+ current_delay = delay
46
+
47
+ while True:
48
+ try:
49
+ return func(*args, **kwargs)
50
+ except exceptions as e:
51
+ retries += 1
52
+ if retries > max_retries:
53
+ logger.error(
54
+ f"Function {func.__name__} failed after {max_retries} retries. "
55
+ f"Final error: {str(e)}"
56
+ )
57
+ raise
58
+
59
+ logger.warning(
60
+ f"Retry {retries}/{max_retries} for function {func.__name__} "
61
+ f"after error: {str(e)}. "
62
+ f"Waiting {current_delay} seconds..."
63
+ )
64
+
65
+ time.sleep(current_delay)
66
+ current_delay *= backoff_factor
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: swarms
3
- Version: 7.9.0
3
+ Version: 7.9.1
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
@@ -105,8 +105,8 @@ swarms/schemas/llm_agent_schema.py,sha256=S5ZIF21q-I9EUtQpgKYZc361o5FGFOnrW_6YTK
105
105
  swarms/schemas/mcp_schemas.py,sha256=XZJ4HyiY_cv8Gvj-53ddjzXuqT9hBU2f0cHbhIKs_jY,1330
106
106
  swarms/schemas/swarms_api_schemas.py,sha256=uKqleW_7hNpqHi06yoba9jS2i9yzZp-SBV944MnkN68,6233
107
107
  swarms/schemas/tool_schema_base_model.py,sha256=0biTGIoibsPPP3fOrkC6WvNU5vXaalyccVKC1fpO_eg,1409
108
- swarms/structs/__init__.py,sha256=XbUK6MSivL9qHNFlcoGcAVRYPupQssD3dG_-yAqrycw,4345
109
- swarms/structs/agent.py,sha256=qgt-DsX6kJCxKJYLUIXkT6QnoRGO4DpOXHCWRQI_gjU,115570
108
+ swarms/structs/__init__.py,sha256=8_CG2mct9cS-TQlpKlC5-240kSjmoooy9bfYXRuB9oQ,4552
109
+ swarms/structs/agent.py,sha256=KFlloIhQQivm5hTtNI2ZFzqs4bRaC5cMaqs2mnOA-eY,120067
110
110
  swarms/structs/agent_builder.py,sha256=tYNpfO4_8cgfMHfgA5DAOWffHnt70p6CLt59esqfVCY,12133
111
111
  swarms/structs/agent_rag_handler.py,sha256=g17YRrNmf16TLvyFCCcsitVk3d-QNZmck_XYmjSN_YM,21372
112
112
  swarms/structs/agent_registry.py,sha256=il507cO1NF-d4ChyANVLuWrN8bXsEAi8_7bLJ_sTU6A,12112
@@ -120,7 +120,7 @@ swarms/structs/base_workflow.py,sha256=DTfFwX3AdFYxACDYwUDqhsbcDZnITlg5TeEYyxmJB
120
120
  swarms/structs/batch_agent_execution.py,sha256=d85DzeCq4uTbbPqLhAXFqFx_cxXUS5yRnJ1-gJkwU5w,1871
121
121
  swarms/structs/concat.py,sha256=utezSxNyh1mIwXgdf8-dJ803NDPyEy79WE8zJHuooGk,732
122
122
  swarms/structs/concurrent_workflow.py,sha256=uwDDqxG_6pc_rnJTOQH6njeaNbVfieehqCzdPCi162A,8350
123
- swarms/structs/conversation.py,sha256=06CY2vHXbKr9egwPsQMxZbanxEvuMnuLI-8MXz7v5Bo,49390
123
+ swarms/structs/conversation.py,sha256=mmsvR15zWxsJ4dgyxwwunIifvfcVO4gfJr5zl0RxaSA,52258
124
124
  swarms/structs/council_judge.py,sha256=siYDKiHMvFmShUTXxdo4R6vXiQhKt7bEBI205oC3kU4,19639
125
125
  swarms/structs/csv_to_agent.py,sha256=Zv41sjeWA50msq-paGHESzlxZyMU78DYDLNNKZtNfoI,11125
126
126
  swarms/structs/de_hallucination_swarm.py,sha256=9cC0rSSXGwYu6SRDwpeMbCcQ40C1WI1RE9SNapKRLOQ,10309
@@ -131,7 +131,7 @@ swarms/structs/groupchat.py,sha256=jjH0BqU9Nrd_3jl9QzrcvbSce527SFpUaepawaRiw2o,1
131
131
  swarms/structs/hiearchical_swarm.py,sha256=6JwYWlsmwsVtOr2xlzl2q0IRsGvr-RFzDG9ClIJWTQo,33400
132
132
  swarms/structs/hybrid_hiearchical_peer_swarm.py,sha256=0BrmzSVit-I_04DFfrs7onLblLA6PSPa0JE3-4j05FA,9316
133
133
  swarms/structs/image_batch_processor.py,sha256=31Z8vTVL4dw18QxGwb0Jg1nvp0YzX8lwVgGj_-KrkhY,8207
134
- swarms/structs/interactive_groupchat.py,sha256=WjsdFgAm4zaqxchAq2mpMPefvHXEhqiJFH7HVvUdfRw,24601
134
+ swarms/structs/interactive_groupchat.py,sha256=tlI4BiDRKQK2YtHvbWvT-Z0rhfpfsywavj1CHfZc7F8,41169
135
135
  swarms/structs/long_agent.py,sha256=KFjE2uUI8ONTkeJO43Sh3y5-Ec0kga28BECGklic-S4,15049
136
136
  swarms/structs/ma_blocks.py,sha256=04dF3DOSHXxNwrcl9QUloKgNDkI9yLRv6UbyyiKsIb0,4551
137
137
  swarms/structs/ma_utils.py,sha256=XJYxqWxFKBmdDekdX_BVGmmBxLbnz7hURMS2ZpVIcK8,3854
@@ -156,7 +156,7 @@ swarms/structs/swarm_eval.py,sha256=148E2R2zaCmt_LZYx15nmdFjybXHiQ2CZbl6pk77jNs,
156
156
  swarms/structs/swarm_id_generator.py,sha256=Wly7AtGM9e6VgzhYmfg8_gSOdxAdsOvWHJFK81cpQNQ,68
157
157
  swarms/structs/swarm_matcher.py,sha256=HUCxTWRnxT5Rix3CMKEuJCqNleqPA9xGrWFGw6rjcTw,26821
158
158
  swarms/structs/swarm_registry.py,sha256=P0XRrqp1qBNyt0BycqPQljUzKv9jClaQMhtaBMinhYg,5578
159
- swarms/structs/swarm_router.py,sha256=-yvC_RGEO_DISA9F9Yk7Q7SvFObTh8XDOYvwBFWm6GQ,26464
159
+ swarms/structs/swarm_router.py,sha256=cr_-bx_Axhq3FM9UyRmgyg3CfVKGU012ZPnYdaYClB0,26574
160
160
  swarms/structs/swarming_architectures.py,sha256=guNQU2N7Ofuk01fZbU3tmBJymnZ9zdGULpPZAdaqCeA,28276
161
161
  swarms/structs/tree_swarm.py,sha256=AnIxrt0KhWxAQN8uGjfCcOq-XCmsuTJiH8Ex4mXy8V8,12500
162
162
  swarms/structs/utils.py,sha256=Mo6wHQYOB8baWZUKnAJN5Dsgubpo81umNwJIEDitb2A,1873
@@ -198,17 +198,18 @@ swarms/utils/generate_keys.py,sha256=o5zp_8rwu5sgQnItWS1xAuIIRIkahwm02qy1vsV6DSQ
198
198
  swarms/utils/history_output_formatter.py,sha256=whjfk4N5SjMo3mtrafNny_alNiAhQcGza3l1dCyg7Nw,1388
199
199
  swarms/utils/index.py,sha256=iYVlMiuSpBuKHF34uSrxDUuSYmS26bbYoAqyz_VIyvY,6902
200
200
  swarms/utils/litellm_tokenizer.py,sha256=PqzAY4C5lJ3P-K9SL-dCNtxmHHlZvAw1UohT-ob9lxY,3389
201
- swarms/utils/litellm_wrapper.py,sha256=v8_Wb3fkm_iYq0gTajaI2-RGLjFCd0_znIVHzgyVkuY,19712
201
+ swarms/utils/litellm_wrapper.py,sha256=gq1SzskOqTRSfOUjQWDp1huFYRUiVcm23CBnvqeZUfs,19748
202
202
  swarms/utils/loguru_logger.py,sha256=hIoSK3NHLpe7eAmjHRURrEYzNXYC2gbR7_Vv63Yaydk,685
203
203
  swarms/utils/output_types.py,sha256=jPOiRr2s114Dw2ngG8DTtxHIWZikMfNtXkyLtgghj9w,404
204
204
  swarms/utils/parse_code.py,sha256=XFOLymbdP3HzMZuqsj7pwUyisvUmTm0ev9iThR_ambI,1987
205
205
  swarms/utils/pdf_to_text.py,sha256=nkySOS_sJ4Jf4RP5SoDpMB5WfjJ_GGc5z8gJfn2cxOM,1311
206
+ swarms/utils/retry_func.py,sha256=uGdgRUV4OuZSXM9_Sec1YNumnNL3IXGEc3zZbm_f3z0,2104
206
207
  swarms/utils/str_to_dict.py,sha256=T3Jsdjz87WIlkSo7jAW6BB80sv0Ns49WT1qXlOrdEoE,874
207
208
  swarms/utils/try_except_wrapper.py,sha256=uvDZDZJcH986EF0Ej6zZBLcqHJ58NHizPsAH5olrE7Q,3919
208
209
  swarms/utils/vllm_wrapper.py,sha256=sNkm4EbeMrqqmHidnvq5zTnofQAaARy3HIrNBu11lKs,5072
209
210
  swarms/utils/xml_utils.py,sha256=D4nEdo1nkHqSoTKrWylXBXjcHFhGaOYvvfGNQQoYV5o,2514
210
- swarms-7.9.0.dist-info/LICENSE,sha256=jwRtEmTWjLrEsvFB6QFdYs2cEeZPRMdj-UMOFkPF8_0,11363
211
- swarms-7.9.0.dist-info/METADATA,sha256=975yPHfdUcd813Gqer_ZCOwXe-A8QoHlQ2adMxayHoU,32138
212
- swarms-7.9.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
213
- swarms-7.9.0.dist-info/entry_points.txt,sha256=2K0rTtfO1X1WaO-waJlXIKw5Voa_EpAL_yU0HXE2Jgc,47
214
- swarms-7.9.0.dist-info/RECORD,,
211
+ swarms-7.9.1.dist-info/LICENSE,sha256=jwRtEmTWjLrEsvFB6QFdYs2cEeZPRMdj-UMOFkPF8_0,11363
212
+ swarms-7.9.1.dist-info/METADATA,sha256=REGmsTOGNRQj0n3oqtsbv6v3VMSMt8DsnR5Nvol53GA,32138
213
+ swarms-7.9.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
214
+ swarms-7.9.1.dist-info/entry_points.txt,sha256=2K0rTtfO1X1WaO-waJlXIKw5Voa_EpAL_yU0HXE2Jgc,47
215
+ swarms-7.9.1.dist-info/RECORD,,
File without changes