diff --git a/swarms/tools/func_calling_utils.py b/swarms/tools/func_calling_utils.py index c5a5bd83..b02a95ec 100644 --- a/swarms/tools/func_calling_utils.py +++ b/swarms/tools/func_calling_utils.py @@ -122,9 +122,9 @@ def prepare_output_for_output_model( """ if output_type == BaseModel: return str_to_pydantic_model(output, output_type) - elif output_type == dict: + elif output_type is dict: return dict_to_json_str(output) - elif output_type == str: + elif output_type is str: return output else: return output diff --git a/tests/agent_evals/auto_test_eval.py b/tests/agent_evals/auto_test_eval.py index b9c770fa..43205ecb 100644 --- a/tests/agent_evals/auto_test_eval.py +++ b/tests/agent_evals/auto_test_eval.py @@ -102,17 +102,28 @@ class SwarmsIssueReporter: return "Unknown" def _get_gpu_info(self) -> Tuple[bool, Optional[str]]: - """Get GPU information and CUDA availability.""" - try: - import torch + """Get GPU information and CUDA availability.""" + try: + import torch + + cuda_available = torch.cuda.is_available() + if cuda_available: + gpu_info = torch.cuda.get_device_name(0) + return cuda_available, gpu_info + return False, None + except ModuleNotFoundError as e: + # Handle the case where 'torch' is not installed + print(f"Error: {e}") + return False, None + except RuntimeError as e: + # Handle CUDA-related errors + print(f"Error: {e}") + return False, None + except Exception as e: + # Catch any other exceptions + print(f"Unexpected error: {e}") + return False, None - cuda_available = torch.cuda.is_available() - if cuda_available: - gpu_info = torch.cuda.get_device_name(0) - return cuda_available, gpu_info - return False, None - except: - return False, None def _get_system_info(self) -> SwarmSystemInfo: """Collect system and Swarms-specific information.""" @@ -199,16 +210,23 @@ class SwarmsIssueReporter: """ def _get_dependencies_info(self) -> str: - """Get information about installed dependencies.""" - try: - import pkg_resources + """Get information about installed dependencies.""" + try: + import pkg_resources + + deps = [] + for dist in pkg_resources.working_set: + deps.append(f"- {dist.key} {dist.version}") + return "\n".join(deps) + except ImportError as e: + # Handle the case where pkg_resources is not available + print(f"Error: {e}") + return "Unable to fetch dependency information" + except Exception as e: + # Catch any other unexpected exceptions + print(f"Unexpected error: {e}") + return "Unable to fetch dependency information" - deps = [] - for dist in pkg_resources.working_set: - deps.append(f"- {dist.key} {dist.version}") - return "\n".join(deps) - except: - return "Unable to fetch dependency information" # First, add this method to your SwarmsIssueReporter class def _check_rate_limit(self) -> bool: diff --git a/tests/profiling_agent.py b/tests/profiling_agent.py index 8f1b0220..cb04552c 100644 --- a/tests/profiling_agent.py +++ b/tests/profiling_agent.py @@ -1,7 +1,4 @@ import time - -start_time = time.time() - import os import uuid from swarms import Agent @@ -9,7 +6,7 @@ from swarm_models import OpenAIChat from swarms.prompts.finance_agent_sys_prompt import ( FINANCIAL_AGENT_SYS_PROMPT, ) - +start_time = time.time() # Get the OpenAI API key from the environment variable api_key = os.getenv("OPENAI_API_KEY")