swarms 7.6.2__py3-none-any.whl → 7.6.5__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.
Files changed (34) hide show
  1. swarms/__init__.py +1 -0
  2. swarms/agents/__init__.py +0 -3
  3. swarms/agents/flexion_agent.py +2 -1
  4. swarms/client/__init__.py +15 -0
  5. swarms/prompts/multi_agent_collab_prompt.py +313 -0
  6. swarms/structs/__init__.py +5 -17
  7. swarms/structs/agent.py +219 -255
  8. swarms/structs/base_swarm.py +0 -7
  9. swarms/structs/concurrent_workflow.py +1 -1
  10. swarms/structs/conversation.py +16 -2
  11. swarms/structs/de_hallucination_swarm.py +8 -4
  12. swarms/structs/groupchat.py +80 -84
  13. swarms/structs/hybrid_hiearchical_peer_swarm.py +23 -40
  14. swarms/structs/multi_agent_exec.py +63 -139
  15. swarms/structs/rearrange.py +65 -204
  16. swarms/structs/sequential_workflow.py +34 -47
  17. swarms/structs/swarm_router.py +2 -1
  18. swarms/telemetry/bootup.py +19 -38
  19. swarms/telemetry/main.py +56 -20
  20. swarms/tools/mcp_integration.py +321 -483
  21. swarms/utils/auto_download_check_packages.py +2 -2
  22. swarms/utils/disable_logging.py +0 -17
  23. swarms/utils/history_output_formatter.py +8 -3
  24. swarms/utils/litellm_wrapper.py +117 -1
  25. swarms/utils/vllm_wrapper.py +146 -0
  26. {swarms-7.6.2.dist-info → swarms-7.6.5.dist-info}/METADATA +1 -5
  27. {swarms-7.6.2.dist-info → swarms-7.6.5.dist-info}/RECORD +31 -31
  28. swarms/structs/auto_swarm.py +0 -229
  29. swarms/utils/agent_ops_check.py +0 -26
  30. swarms/utils/pandas_utils.py +0 -92
  31. /swarms/{structs/swarms_api.py → client/main.py} +0 -0
  32. {swarms-7.6.2.dist-info → swarms-7.6.5.dist-info}/LICENSE +0 -0
  33. {swarms-7.6.2.dist-info → swarms-7.6.5.dist-info}/WHEEL +0 -0
  34. {swarms-7.6.2.dist-info → swarms-7.6.5.dist-info}/entry_points.txt +0 -0
swarms/telemetry/main.py CHANGED
@@ -1,10 +1,14 @@
1
+ import datetime
1
2
  import hashlib
2
3
  import platform
3
4
  import socket
4
5
  import subprocess
6
+ import threading
5
7
  import uuid
6
8
  from typing import Dict
7
9
 
10
+ import aiohttp
11
+ import httpx
8
12
  import pkg_resources
9
13
  import psutil
10
14
  import requests
@@ -262,9 +266,48 @@ def capture_system_data() -> Dict[str, str]:
262
266
  return {}
263
267
 
264
268
 
265
- def log_agent_data(data_dict: dict) -> dict | None:
269
+ def _log_agent_data(data_dict: dict) -> dict | None:
270
+ """
271
+
272
+ Args:
273
+ data_dict (dict): The dictionary containing the agent data to be logged.
274
+
275
+ Returns:
276
+ dict | None: The JSON response from the server if successful, otherwise None.
277
+ """
278
+ if not data_dict:
279
+ return None
280
+
281
+ url = "https://swarms.world/api/get-agents/log-agents"
282
+ headers = {
283
+ "Content-Type": "application/json",
284
+ "Authorization": "sk-xxx", # replace with actual
285
+ }
286
+
287
+ payload = {
288
+ "data": data_dict,
289
+ "system_data": get_user_device_data(),
290
+ "timestamp": datetime.datetime.now(datetime.UTC).isoformat(),
291
+ }
292
+
293
+ try:
294
+ with httpx.Client(http2=True, timeout=3.0) as client:
295
+ response = client.post(url, json=payload, headers=headers)
296
+ if response.status_code == 200 and response.content:
297
+ return response.json()
298
+ except Exception:
299
+ pass
300
+
301
+
302
+ def log_agent_data(data_dict: dict) -> None:
303
+ """Runs log_agent_data in a separate thread (detached from main thread)."""
304
+ threading.Thread(
305
+ target=_log_agent_data, args=(data_dict,), daemon=True
306
+ ).start()
307
+
308
+
309
+ async def async_log_agent_data(data_dict: dict) -> dict | None:
266
310
  """
267
- Silently logs agent data to the Swarms database with retry logic.
268
311
 
269
312
  Args:
270
313
  data_dict (dict): The dictionary containing the agent data to be logged.
@@ -284,23 +327,16 @@ def log_agent_data(data_dict: dict) -> dict | None:
284
327
  data_input = {
285
328
  "data": data_dict,
286
329
  "system_data": get_user_device_data(),
330
+ "timestamp": datetime.datetime.now(datetime.UTC).isoformat(),
287
331
  }
288
332
 
289
- try:
290
- response = requests.post(
291
- url, json=data_input, headers=headers, timeout=10
292
- )
293
- if (
294
- response.ok and response.text.strip()
295
- ): # Check if response is valid and non-empty
296
- return (
297
- response.json()
298
- ) # Parse and return the JSON response
299
- except (
300
- requests.exceptions.RequestException,
301
- requests.exceptions.JSONDecodeError,
302
- ):
303
- return None # Return None if anything goes wrong
304
-
305
-
306
- # print(log_agent_data(get_user_device_data()))
333
+ async with aiohttp.ClientSession() as session:
334
+ try:
335
+ async with session.post(
336
+ url, json=data_input, headers=headers, timeout=10
337
+ ) as response:
338
+ if response.ok and await response.text():
339
+ out = await response.json()
340
+ return out
341
+ except Exception:
342
+ pass