pull/25/head
Kye 1 year ago
parent a6f815d01c
commit 96b51b988a

@ -4,7 +4,7 @@ from setuptools import setup, find_packages
setup( setup(
name = 'swarms', name = 'swarms',
packages = find_packages(exclude=[]), packages = find_packages(exclude=[]),
version = '0.9.3', version = '0.9.4',
license='MIT', license='MIT',
description = 'Swarms - Pytorch', description = 'Swarms - Pytorch',
author = 'Kye Gomez', author = 'Kye Gomez',

@ -176,8 +176,8 @@ class Swarms:
logging.error(f"An error occurred in run_swarms: {e}") logging.error(f"An error occurred in run_swarms: {e}")
return None return None
# usage- # usage-# usage-
def swarm(api_key="", objective=""): async def swarm(api_key="", objective=""):
""" """
Run the swarm with the given API key and objective. Run the swarm with the given API key and objective.
@ -197,15 +197,12 @@ def swarm(api_key="", objective=""):
raise ValueError("A valid objective is required") raise ValueError("A valid objective is required")
try: try:
swarms = Swarms(api_key) swarms = Swarms(api_key)
loop = asyncio.get_event_loop() result = await swarms.run_swarms(objective)
tasks = [loop.create_task(swarms.run_swarms(objective))] if result is None:
completed, pending = loop.run_until_complete(asyncio.wait(tasks))
results = [t.result() for t in completed]
if not results or any(result is None for result in results):
logging.error("Failed to run swarms") logging.error("Failed to run swarms")
else: else:
logging.info(f"Successfully ran swarms with results: {results}") logging.info(f"Successfully ran swarms with results: {result}")
return results return result
except Exception as e: except Exception as e:
logging.error(f"An error occured in swarm: {e}") logging.error(f"An error occured in swarm: {e}")
return None return None
Loading…
Cancel
Save