various bug fixes and removed mcp and other optimizations

pull/796/merge
Kye Gomez 5 days ago
parent d603604ccf
commit 4f209580de

@ -1,4 +1,4 @@
from swarms import Agent from swarms.structs.agent import Agent
from swarms.prompts.finance_agent_sys_prompt import ( from swarms.prompts.finance_agent_sys_prompt import (
FINANCIAL_AGENT_SYS_PROMPT, FINANCIAL_AGENT_SYS_PROMPT,
) )
@ -13,7 +13,7 @@ agent = Agent(
agent_description="Personal finance advisor agent", agent_description="Personal finance advisor agent",
system_prompt=FINANCIAL_AGENT_SYS_PROMPT, system_prompt=FINANCIAL_AGENT_SYS_PROMPT,
max_loops=2, max_loops=2,
model_name="groq/llama-3.3-70b-versatile", model_name="gpt-4o-mini",
dynamic_temperature_enabled=True, dynamic_temperature_enabled=True,
user_name="swarms_corp", user_name="swarms_corp",
retry_attempts=3, retry_attempts=3,
@ -27,8 +27,6 @@ agent = Agent(
role="director", role="director",
) )
print( agent.run(
agent.run( "Conduct an analysis of the best real undervalued ETFs. Think for 2 loops internally"
"Conduct an analysis of the best real undervalued ETFs. Think for 2 loops internally"
)
) )

@ -0,0 +1,13 @@
from swarms.structs.auto_swarm_builder import AutoSwarmBuilder
example = AutoSwarmBuilder(
name="ContentCreation-Swarm",
description="A swarm of specialized AI agents for research, writing, editing, and publishing that maintain brand consistency across channels while automating distribution.",
max_loops=1,
)
print(
example.run(
"Build agents for research, writing, editing, and publishing to enhance brand consistency and automate distribution across channels."
)
)

@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry] [tool.poetry]
name = "swarms" name = "swarms"
version = "7.6.7" version = "7.7.0"
description = "Swarms - TGSC" description = "Swarms - TGSC"
license = "MIT" license = "MIT"
authors = ["Kye Gomez <kye@apac.ai>"] authors = ["Kye Gomez <kye@apac.ai>"]
@ -77,7 +77,6 @@ numpy = "*"
litellm = "*" litellm = "*"
torch = "*" torch = "*"
httpx = "*" httpx = "*"
mcp = "*"
[tool.poetry.scripts] [tool.poetry.scripts]
swarms = "swarms.cli.main:main" swarms = "swarms.cli.main:main"

@ -7,6 +7,7 @@ from swarms.telemetry.bootup import bootup # noqa: E402, F403
bootup() bootup()
from swarms.agents import * # noqa: E402, F403 from swarms.agents import * # noqa: E402, F403
from swarms.artifacts import * # noqa: E402, F403 from swarms.artifacts import * # noqa: E402, F403
from swarms.prompts import * # noqa: E402, F403 from swarms.prompts import * # noqa: E402, F403
from swarms.schemas import * # noqa: E402, F403 from swarms.schemas import * # noqa: E402, F403

@ -46,11 +46,12 @@ from swarms.structs.safe_loading import (
) )
from swarms.telemetry.main import log_agent_data from swarms.telemetry.main import log_agent_data
from swarms.tools.base_tool import BaseTool from swarms.tools.base_tool import BaseTool
from swarms.tools.mcp_integration import (
MCPServerSseParams, # from swarms.tools.mcp_integration import (
batch_mcp_flow, # MCPServerSseParams,
mcp_flow_get_tool_schema, # batch_mcp_flow,
) # mcp_flow_get_tool_schema,
# )
from swarms.tools.tool_parse_exec import parse_and_execute_json from swarms.tools.tool_parse_exec import parse_and_execute_json
from swarms.utils.any_to_str import any_to_str from swarms.utils.any_to_str import any_to_str
from swarms.utils.data_to_text import data_to_text from swarms.utils.data_to_text import data_to_text
@ -62,7 +63,6 @@ from swarms.utils.history_output_formatter import (
from swarms.utils.litellm_tokenizer import count_tokens from swarms.utils.litellm_tokenizer import count_tokens
from swarms.utils.litellm_wrapper import LiteLLM from swarms.utils.litellm_wrapper import LiteLLM
from swarms.utils.pdf_to_text import pdf_to_text from swarms.utils.pdf_to_text import pdf_to_text
from swarms.utils.str_to_dict import str_to_dict
# Utils # Utils
@ -403,7 +403,7 @@ class Agent:
role: agent_roles = "worker", role: agent_roles = "worker",
no_print: bool = False, no_print: bool = False,
tools_list_dictionary: Optional[List[Dict[str, Any]]] = None, tools_list_dictionary: Optional[List[Dict[str, Any]]] = None,
mcp_servers: List[MCPServerSseParams] = [], # mcp_servers: List[MCPServerSseParams] = [],
*args, *args,
**kwargs, **kwargs,
): ):
@ -523,7 +523,7 @@ class Agent:
self.role = role self.role = role
self.no_print = no_print self.no_print = no_print
self.tools_list_dictionary = tools_list_dictionary self.tools_list_dictionary = tools_list_dictionary
self.mcp_servers = mcp_servers # self.mcp_servers = mcp_servers
self._cached_llm = ( self._cached_llm = (
None # Add this line to cache the LLM instance None # Add this line to cache the LLM instance
) )
@ -643,11 +643,11 @@ class Agent:
if self.llm is None: if self.llm is None:
self.llm = self.llm_handling() self.llm = self.llm_handling()
if ( # if (
self.tools_list_dictionary is None # self.tools_list_dictionary is None
and self.mcp_servers is not None # and self.mcp_servers is not None
): # ):
self.tools_list_dictionary = self.mcp_tool_handling() # self.tools_list_dictionary = self.mcp_tool_handling()
def llm_handling(self): def llm_handling(self):
# Use cached instance if available # Use cached instance if available
@ -695,68 +695,68 @@ class Agent:
) )
return None return None
def mcp_execution_flow(self, response: any): # def mcp_execution_flow(self, response: any):
""" # """
Executes the MCP (Model Context Protocol) flow based on the provided response. # Executes the MCP (Model Context Protocol) flow based on the provided response.
This method takes a response, converts it from a string to a dictionary format, # This method takes a response, converts it from a string to a dictionary format,
and checks for the presence of a tool name or a name in the response. If either # and checks for the presence of a tool name or a name in the response. If either
is found, it retrieves the tool name and proceeds to call the batch_mcp_flow # is found, it retrieves the tool name and proceeds to call the batch_mcp_flow
function to execute the corresponding tool actions. # function to execute the corresponding tool actions.
Args: # Args:
response (any): The response to be processed, which can be in string format # response (any): The response to be processed, which can be in string format
that represents a dictionary. # that represents a dictionary.
Returns: # Returns:
The output from the batch_mcp_flow function, which contains the results of # The output from the batch_mcp_flow function, which contains the results of
the tool execution. If an error occurs during processing, it logs the error # the tool execution. If an error occurs during processing, it logs the error
and returns None. # and returns None.
Raises: # Raises:
Exception: Logs any exceptions that occur during the execution flow. # Exception: Logs any exceptions that occur during the execution flow.
""" # """
try: # try:
response = str_to_dict(response) # response = str_to_dict(response)
tool_output = batch_mcp_flow( # tool_output = batch_mcp_flow(
self.mcp_servers, # self.mcp_servers,
function_call=response, # function_call=response,
) # )
return tool_output # return tool_output
except Exception as e: # except Exception as e:
logger.error(f"Error in mcp_execution_flow: {e}") # logger.error(f"Error in mcp_execution_flow: {e}")
return None # return None
def mcp_tool_handling(self): # def mcp_tool_handling(self):
""" # """
Handles the retrieval of tool schemas from the MCP servers. # Handles the retrieval of tool schemas from the MCP servers.
This method iterates over the list of MCP servers, retrieves the tool schema # This method iterates over the list of MCP servers, retrieves the tool schema
for each server using the mcp_flow_get_tool_schema function, and compiles # for each server using the mcp_flow_get_tool_schema function, and compiles
these schemas into a list. The resulting list is stored in the # these schemas into a list. The resulting list is stored in the
tools_list_dictionary attribute. # tools_list_dictionary attribute.
Returns: # Returns:
list: A list of tool schemas retrieved from the MCP servers. If an error # list: A list of tool schemas retrieved from the MCP servers. If an error
occurs during the retrieval process, it logs the error and returns None. # occurs during the retrieval process, it logs the error and returns None.
Raises: # Raises:
Exception: Logs any exceptions that occur during the tool handling process. # Exception: Logs any exceptions that occur during the tool handling process.
""" # """
try: # try:
self.tools_list_dictionary = [] # self.tools_list_dictionary = []
for mcp_server in self.mcp_servers: # for mcp_server in self.mcp_servers:
tool_schema = mcp_flow_get_tool_schema(mcp_server) # tool_schema = mcp_flow_get_tool_schema(mcp_server)
self.tools_list_dictionary.append(tool_schema) # self.tools_list_dictionary.append(tool_schema)
print(self.tools_list_dictionary) # print(self.tools_list_dictionary)
return self.tools_list_dictionary # return self.tools_list_dictionary
except Exception as e: # except Exception as e:
logger.error(f"Error in mcp_tool_handling: {e}") # logger.error(f"Error in mcp_tool_handling: {e}")
return None # return None
def setup_config(self): def setup_config(self):
# The max_loops will be set dynamically if the dynamic_loop # The max_loops will be set dynamically if the dynamic_loop
@ -2490,10 +2490,12 @@ class Agent:
**kwargs, **kwargs,
) )
if self.tools_list_dictionary is not None: return output
return str_to_dict(output)
else: # if self.tools_list_dictionary is not None:
return output # return str_to_dict(output)
# else:
# return output
except ValueError as e: except ValueError as e:
self._handle_run_error(e) self._handle_run_error(e)

@ -176,20 +176,20 @@ tools = [
"type": "function", "type": "function",
"function": { "function": {
"name": "search_topic", "name": "search_topic",
"description": "Conduct an in-depth search on a specified topic or subtopic, generating a comprehensive array of highly detailed search queries tailored to the input parameters.", "description": "Conduct a thorough search on a specified topic or subtopic, generating a precise array of highly detailed search queries tailored to the input parameters.",
"parameters": { "parameters": {
"type": "object", "type": "object",
"properties": { "properties": {
"depth": { "depth": {
"type": "integer", "type": "integer",
"description": "Indicates the level of thoroughness for the search. Values range from 1 to 3, where 1 represents a superficial search and 3 signifies an exploration of the topic.", "description": "Indicates the level of thoroughness for the search. Values range from 1 to 3, where 1 signifies a superficial search and 3 indicates an in-depth exploration of the topic.",
}, },
"detailed_queries": { "detailed_queries": {
"type": "array", "type": "array",
"description": "An array of highly specific search queries that are generated based on the input query and the specified depth. Each query should be designed to elicit detailed and relevant information from various sources.", "description": "An array of specific search queries generated based on the input query and the specified depth. Each query must be crafted to elicit detailed and relevant information from various sources.",
"items": { "items": {
"type": "string", "type": "string",
"description": "Each item in this array should represent a unique search query that targets a specific aspect of the main topic, ensuring a comprehensive exploration of the subject matter.", "description": "Each item in this array must represent a unique search query targeting a specific aspect of the main topic, ensuring a comprehensive exploration of the subject matter.",
}, },
}, },
}, },

@ -177,11 +177,6 @@ class AutoSwarmBuilder:
swarm_type=swarm_type, swarm_type=swarm_type,
) )
if not self.api_key:
raise ValueError(
"OpenAI API key must be provided either through initialization or environment variable"
)
logger.info( logger.info(
"Initialized AutoSwarmBuilder", "Initialized AutoSwarmBuilder",
extra={ extra={

@ -1,178 +0,0 @@
import os
from pathlib import Path
from typing import Optional
from swarms.utils.loguru_logger import initialize_logger
logger = initialize_logger("workspace-manager")
class WorkspaceManager:
"""
Manages the workspace directory and settings for the application.
This class is responsible for setting up the workspace directory, logging configuration,
and retrieving environment variables for telemetry and API key.
"""
def __init__(
self,
workspace_dir: Optional[str] = "agent_workspace",
use_telemetry: Optional[bool] = True,
api_key: Optional[str] = None,
):
"""
Initializes the WorkspaceManager with optional parameters for workspace directory,
telemetry usage, and API key.
Args:
workspace_dir (Optional[str]): The path to the workspace directory.
use_telemetry (Optional[bool]): A flag indicating whether to use telemetry.
api_key (Optional[str]): The API key for the application.
"""
self.workspace_dir = workspace_dir
self.use_telemetry = use_telemetry
self.api_key = api_key
def _create_env_file(self, env_file_path: Path) -> None:
"""
Create a new .env file with default WORKSPACE_DIR.
Args:
env_file_path (Path): The path to the .env file.
"""
with env_file_path.open("w") as file:
file.write(f"WORKSPACE_DIR={self.workspace_dir}\n")
logger.info(
"Created a new .env file with default WORKSPACE_DIR."
)
def _append_to_env_file(self, env_file_path: Path) -> None:
"""
Append WORKSPACE_DIR to .env if it doesn't exist.
Args:
env_file_path (Path): The path to the .env file.
"""
with env_file_path.open("r+") as file:
content = file.read()
if "WORKSPACE_DIR" not in content:
file.seek(0, os.SEEK_END)
file.write(f"WORKSPACE_DIR={self.workspace_dir}\n")
logger.info("Appended WORKSPACE_DIR to .env file.")
def _get_workspace_dir(
self, workspace_dir: Optional[str] = None
) -> str:
"""
Get the workspace directory from environment variable or default.
Args:
workspace_dir (Optional[str]): The path to the workspace directory.
Returns:
str: The path to the workspace directory.
"""
return workspace_dir or os.getenv(
"WORKSPACE_DIR", "agent_workspace"
)
def _get_telemetry_status(
self, use_telemetry: Optional[bool] = None
) -> bool:
"""
Get telemetry status from environment variable or default.
Args:
use_telemetry (Optional[bool]): A flag indicating whether to use telemetry.
Returns:
bool: The status of telemetry usage.
"""
return (
use_telemetry
if use_telemetry is not None
else os.getenv("USE_TELEMETRY", "true").lower() == "true"
)
def _get_api_key(
self, api_key: Optional[str] = None
) -> Optional[str]:
"""
Get API key from environment variable or default.
Args:
api_key (Optional[str]): The API key for the application.
Returns:
Optional[str]: The API key or None if not set.
"""
return api_key or os.getenv("SWARMS_API_KEY")
def _init_workspace(self) -> None:
"""
Initialize the workspace directory if it doesn't exist.
"""
if not self.workspace_path.exists():
self.workspace_path.mkdir(parents=True, exist_ok=True)
logger.info("Workspace directory initialized.")
@property
def get_workspace_path(self) -> Path:
"""
Get the workspace path.
Returns:
Path: The path to the workspace directory.
"""
return self.workspace_path
@property
def get_telemetry_status(self) -> bool:
"""
Get telemetry status.
Returns:
bool: The status of telemetry usage.
"""
return self.use_telemetry
@property
def get_api_key(self) -> Optional[str]:
"""
Get API key.
Returns:
Optional[str]: The API key or None if not set.
"""
return self.api_key
def run(self) -> None:
try:
# Check if .env file exists and create it if it doesn't
env_file_path = Path(".env")
# If the .env file doesn't exist, create it
if not env_file_path.exists():
self._create_env_file(env_file_path)
else:
# Append WORKSPACE_DIR to .env if it doesn't exist
self._append_to_env_file(env_file_path)
# Set workspace directory
self.workspace_dir = self._get_workspace_dir(
self.workspace_dir
)
self.workspace_path = Path(self.workspace_dir)
# Set telemetry preference
self.use_telemetry = self._get_telemetry_status(
self.use_telemetry
)
# Set API key
self.api_key = self._get_api_key(self.api_key)
# Initialize workspace
self._init_workspace()
except Exception as e:
logger.error(f"Error initializing WorkspaceManager: {e}")

@ -1,18 +1,25 @@
# Add these imports at the top
import asyncio
import datetime import datetime
import hashlib import hashlib
import platform import platform
import socket import socket
import subprocess import subprocess
import threading
import uuid import uuid
from concurrent.futures import ThreadPoolExecutor
from functools import lru_cache
from threading import Lock
from typing import Dict from typing import Dict
import aiohttp import aiohttp
import httpx
import pkg_resources import pkg_resources
import psutil import psutil
import requests
import toml import toml
from requests import Session
from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry
# Helper functions # Helper functions
@ -251,92 +258,135 @@ def capture_system_data() -> Dict[str, str]:
"architecture": platform.architecture()[0], "architecture": platform.architecture()[0],
} }
# Get external IP address
try:
system_data["external_ip"] = requests.get(
"https://api.ipify.org"
).text
except Exception:
system_data["external_ip"] = "N/A"
return system_data return system_data
except Exception as e: except Exception as e:
# logger.error("Failed to capture system data: {}", e) # logger.error("Failed to capture system data: {}", e)
print(f"Failed to capture system data: {e}") print(f"Failed to capture system data: {e}")
return {}
def _log_agent_data(data_dict: dict) -> dict | None: # Global variables
""" _session = None
_session_lock = Lock()
_executor = ThreadPoolExecutor(max_workers=10)
_aiohttp_session = None
def get_session() -> Session:
"""Thread-safe session getter with optimized connection pooling"""
global _session
if _session is None:
with _session_lock:
if _session is None: # Double-check pattern
_session = Session()
adapter = HTTPAdapter(
pool_connections=1000, # Increased pool size
pool_maxsize=1000, # Increased max size
max_retries=Retry(
total=3,
backoff_factor=0.1,
status_forcelist=[500, 502, 503, 504],
),
pool_block=False, # Non-blocking pool
)
_session.mount("http://", adapter)
_session.mount("https://", adapter)
_session.headers.update(
{
"Content-Type": "application/json",
"Authorization": "Bearer sk-33979fd9a4e8e6b670090e4900a33dbe7452a15ccc705745f4eca2a70c88ea24",
"Connection": "keep-alive", # Enable keep-alive
}
)
return _session
Args:
data_dict (dict): The dictionary containing the agent data to be logged.
Returns: @lru_cache(maxsize=2048, typed=True)
dict | None: The JSON response from the server if successful, otherwise None. def get_user_device_data_cached():
""" """Cached version with increased cache size"""
return get_user_device_data()
async def get_aiohttp_session():
"""Get or create aiohttp session for async requests"""
global _aiohttp_session
if _aiohttp_session is None or _aiohttp_session.closed:
timeout = aiohttp.ClientTimeout(total=10)
connector = aiohttp.TCPConnector(
limit=1000, # Connection limit
ttl_dns_cache=300, # DNS cache TTL
use_dns_cache=True, # Enable DNS caching
keepalive_timeout=60, # Keep-alive timeout
)
_aiohttp_session = aiohttp.ClientSession(
timeout=timeout,
connector=connector,
headers={
"Content-Type": "application/json",
"Authorization": "Bearer sk-33979fd9a4e8e6b670090e4900a33dbe7452a15ccc705745f4eca2a70c88ea24",
},
)
return _aiohttp_session
async def log_agent_data_async(data_dict: dict):
"""Asynchronous version of log_agent_data"""
if not data_dict: if not data_dict:
return None return None
url = "https://swarms.world/api/get-agents/log-agents" url = "https://swarms.world/api/get-agents/log-agents"
headers = {
"Content-Type": "application/json",
"Authorization": "sk-xxx", # replace with actual
}
payload = { payload = {
"data": data_dict, "data": data_dict,
"system_data": get_user_device_data(), "system_data": get_user_device_data_cached(),
"timestamp": datetime.datetime.now(datetime.UTC).isoformat(), "timestamp": datetime.datetime.now(
datetime.timezone.utc
).isoformat(),
} }
session = await get_aiohttp_session()
try: try:
with httpx.Client(http2=True, timeout=3.0) as client: async with session.post(url, json=payload) as response:
response = client.post(url, json=payload, headers=headers) if response.status == 200:
if response.status_code == 200 and response.content: return await response.json()
return response.json()
except Exception: except Exception:
pass return None
def log_agent_data(data_dict: dict) -> None:
"""Runs log_agent_data in a separate thread (detached from main thread)."""
threading.Thread(
target=_log_agent_data, args=(data_dict,), daemon=True
).start()
async def async_log_agent_data(data_dict: dict) -> dict | None: def log_agent_data(data_dict: dict):
""" """
Enhanced log_agent_data with both sync and async capabilities
Args:
data_dict (dict): The dictionary containing the agent data to be logged.
Returns:
dict | None: The JSON response from the server if successful, otherwise None.
""" """
if not data_dict: if not data_dict:
return None # Immediately exit if the input is empty return None
url = "https://swarms.world/api/get-agents/log-agents" # If running in an event loop, use async version
headers = { try:
"Content-Type": "application/json", loop = asyncio.get_event_loop()
"Authorization": "sk-33979fd9a4e8e6b670090e4900a33dbe7452a15ccc705745f4eca2a70c88ea24", if loop.is_running():
} return asyncio.create_task(
log_agent_data_async(data_dict)
)
except RuntimeError:
pass
data_input = { # Fallback to optimized sync version
url = "https://swarms.world/api/get-agents/log-agents"
payload = {
"data": data_dict, "data": data_dict,
"system_data": get_user_device_data(), "system_data": get_user_device_data_cached(),
"timestamp": datetime.datetime.now(datetime.UTC).isoformat(), "timestamp": datetime.datetime.now(
datetime.timezone.utc
).isoformat(),
} }
async with aiohttp.ClientSession() as session: try:
try: session = get_session()
async with session.post( response = session.post(
url, json=data_input, headers=headers, timeout=10 url,
) as response: json=payload,
if response.ok and await response.text(): timeout=10,
out = await response.json() stream=False, # Disable streaming for faster response
return out )
except Exception: if response.ok and response.text.strip():
pass return response.json()
except Exception:
return None

@ -292,8 +292,11 @@ class LiteLLM:
return response.choices[0].message.content return response.choices[0].message.content
# Standard completion # Standard completion
response = completion(**completion_params) if self.stream:
return response.choices[0].message.content return completion(**completion_params)
else:
response = completion(**completion_params)
return response.choices[0].message.content
except LiteLLMException as error: except LiteLLMException as error:
logger.error(f"Error in LiteLLM run: {str(error)}") logger.error(f"Error in LiteLLM run: {str(error)}")
@ -364,16 +367,18 @@ class LiteLLM:
# Standard completion # Standard completion
response = await acompletion(**completion_params) response = await acompletion(**completion_params)
return response.choices[0].message.content
print(response)
return response
except Exception as error: except Exception as error:
logger.error(f"Error in LiteLLM arun: {str(error)}") logger.error(f"Error in LiteLLM arun: {str(error)}")
if "rate_limit" in str(error).lower(): # if "rate_limit" in str(error).lower():
logger.warning( # logger.warning(
"Rate limit hit, retrying with exponential backoff..." # "Rate limit hit, retrying with exponential backoff..."
) # )
await asyncio.sleep(2) # Use async sleep # await asyncio.sleep(2) # Use async sleep
return await self.arun(task, *args, **kwargs) # return await self.arun(task, *args, **kwargs)
raise error raise error
async def _process_batch( async def _process_batch(

@ -1,81 +0,0 @@
from typing import Callable, List, Optional, Union
from swarms.structs.agent import Agent
from swarms.utils.loguru_logger import initialize_logger
logger = initialize_logger(log_folder="swarm_reliability_checks")
def reliability_check(
agents: List[Union[Agent, Callable]],
max_loops: int,
name: Optional[str] = None,
description: Optional[str] = None,
flow: Optional[str] = None,
) -> None:
"""
Performs reliability checks on swarm configuration parameters.
Args:
agents: List of Agent objects or callables that will be executed
max_loops: Maximum number of execution loops
name: Name identifier for the swarm
description: Description of the swarm's purpose
Raises:
ValueError: If any parameters fail validation checks
TypeError: If parameters are of incorrect type
"""
logger.info("Initializing swarm reliability checks")
# Type checking
if not isinstance(agents, list):
raise TypeError("agents parameter must be a list")
if not isinstance(max_loops, int):
raise TypeError("max_loops must be an integer")
# Validate agents
if not agents:
raise ValueError("Agents list cannot be empty")
for i, agent in enumerate(agents):
if not isinstance(agent, (Agent, Callable)):
raise TypeError(
f"Agent at index {i} must be an Agent instance or Callable"
)
# Validate max_loops
if max_loops <= 0:
raise ValueError("max_loops must be greater than 0")
if max_loops > 1000:
logger.warning(
"Large max_loops value detected. This may impact performance."
)
# Validate name
if name is None:
raise ValueError("name parameter is required")
if not isinstance(name, str):
raise TypeError("name must be a string")
if len(name.strip()) == 0:
raise ValueError("name cannot be empty or just whitespace")
# Validate description
if description is None:
raise ValueError("description parameter is required")
if not isinstance(description, str):
raise TypeError("description must be a string")
if len(description.strip()) == 0:
raise ValueError(
"description cannot be empty or just whitespace"
)
# Validate flow
if flow is None:
raise ValueError("flow parameter is required")
if not isinstance(flow, str):
raise TypeError("flow must be a string")
logger.info("All reliability checks passed successfully")

@ -26,18 +26,11 @@ class BrowserAgent:
swarm = ConcurrentWorkflow( swarm = ConcurrentWorkflow(
agents=[BrowserAgent() for _ in range(3)], agents=[BrowserAgent() for _ in range(10)],
) )
swarm.run( swarm.run(
""" """
Go to pump.fun. Go to coinpost.jp and find the latest news about the crypto market.
2. Make an account: use email: "test@test.com" and password: "test1234"
3. Make a coin called and give it a cool description and etc. Fill in the form
4. Sit back and watch the coin grow in value.
""" """
) )

@ -0,0 +1,16 @@
from swarms.utils.litellm_wrapper import LiteLLM
llm = LiteLLM(
model_name="gpt-4o-mini",
temperature=0.5,
max_tokens=1000,
stream=True,
)
out = llm.run("What is the capital of France?")
print(out)
for chunk in out:
out = chunk["choices"][0]["delta"]
print(type(out))
print(out)
Loading…
Cancel
Save