Skip to content

Commit

Permalink
adding workspace init in agent.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Occupying-Mars committed Dec 3, 2024
1 parent db16ce4 commit 053644a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 6 additions & 3 deletions swarms/structs/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def __init__(
frequency_penalty: float = 0.0,
presence_penalty: float = 0.0,
temperature: float = 0.1,
workspace_dir: str = "agent_workspace",
workspace_dir: str = None,
timeout: Optional[int] = None,
# short_memory: Optional[str] = None,
created_at: float = time.time(),
Expand Down Expand Up @@ -426,7 +426,7 @@ def __init__(
self.frequency_penalty = frequency_penalty
self.presence_penalty = presence_penalty
self.temperature = temperature
self.workspace_dir = workspace_dir
self.workspace_dir = workspace_dir or os.getenv("WORKSPACE_DIR", "./workspace")
self.timeout = timeout
self.created_at = created_at
self.return_step_meta = return_step_meta
Expand Down Expand Up @@ -469,7 +469,10 @@ def __init__(
self.executor = ThreadPoolExecutor(
max_workers=executor_workers
)

#check and create workspace dir
if not os.path.exists(self.workspace_dir):
os.makedirs(self.workspace_dir)

# Initialize the tool struct
if (
exists(tools)
Expand Down
5 changes: 4 additions & 1 deletion swarms/telemetry/check_update.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import importlib.util
import sys

import os
import pkg_resources
import requests
from packaging import version
Expand Down Expand Up @@ -47,6 +47,9 @@ def check_for_update() -> bool:
"""
try:
# Fetch the latest version from the PyPI API
auto_update = os.getenv("SWARMS_AUTOUPDATE_ON", "false").lower() == "true"
if not auto_update:
return
response = requests.get("https://pypi.org/pypi/swarms/json")
response.raise_for_status() # Raises an HTTPError if the response status code is 4XX/5XX
latest_version = response.json()["info"]["version"]
Expand Down

0 comments on commit 053644a

Please sign in to comment.