fixing issues with linting tests ruff

pull/700/head
Patrick Devaney 3 weeks ago
parent a359c058f3
commit 50476b9a84

@ -122,9 +122,9 @@ def prepare_output_for_output_model(
""" """
if output_type == BaseModel: if output_type == BaseModel:
return str_to_pydantic_model(output, output_type) return str_to_pydantic_model(output, output_type)
elif output_type == dict: elif output_type is dict:
return dict_to_json_str(output) return dict_to_json_str(output)
elif output_type == str: elif output_type is str:
return output return output
else: else:
return output return output

@ -111,8 +111,19 @@ class SwarmsIssueReporter:
gpu_info = torch.cuda.get_device_name(0) gpu_info = torch.cuda.get_device_name(0)
return cuda_available, gpu_info return cuda_available, gpu_info
return False, None return False, None
except: 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 return False, None
except Exception as e:
# Catch any other exceptions
print(f"Unexpected error: {e}")
return False, None
def _get_system_info(self) -> SwarmSystemInfo: def _get_system_info(self) -> SwarmSystemInfo:
"""Collect system and Swarms-specific information.""" """Collect system and Swarms-specific information."""
@ -207,9 +218,16 @@ class SwarmsIssueReporter:
for dist in pkg_resources.working_set: for dist in pkg_resources.working_set:
deps.append(f"- {dist.key} {dist.version}") deps.append(f"- {dist.key} {dist.version}")
return "\n".join(deps) return "\n".join(deps)
except: 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" return "Unable to fetch dependency information"
# First, add this method to your SwarmsIssueReporter class # First, add this method to your SwarmsIssueReporter class
def _check_rate_limit(self) -> bool: def _check_rate_limit(self) -> bool:
"""Check if we're within rate limits.""" """Check if we're within rate limits."""

@ -1,7 +1,4 @@
import time import time
start_time = time.time()
import os import os
import uuid import uuid
from swarms import Agent from swarms import Agent
@ -9,7 +6,7 @@ from swarm_models import OpenAIChat
from swarms.prompts.finance_agent_sys_prompt import ( from swarms.prompts.finance_agent_sys_prompt import (
FINANCIAL_AGENT_SYS_PROMPT, FINANCIAL_AGENT_SYS_PROMPT,
) )
start_time = time.time()
# Get the OpenAI API key from the environment variable # Get the OpenAI API key from the environment variable
api_key = os.getenv("OPENAI_API_KEY") api_key = os.getenv("OPENAI_API_KEY")

Loading…
Cancel
Save