Skip to content

Commit

Permalink
Merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
bonk1t committed Dec 19, 2023
2 parents 3768810 + d9e611d commit 0a61ef3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion nalgonda/agency_config_lock_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class AgencyConfigLockManager:
"""

# Mapping from agency ID to its corresponding Lock.
_locks: "defaultdict[str, threading.Lock]" = defaultdict(threading.Lock)
_locks: dict[str, threading.Lock] = defaultdict(threading.Lock)

@classmethod
def get_lock(cls, agency_id: str) -> threading.Lock:
Expand Down
3 changes: 1 addition & 2 deletions nalgonda/custom_tools/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
from pathlib import Path

from agency_swarm.util import get_openai_client
Expand Down Expand Up @@ -26,7 +25,7 @@ def check_directory_traversal(directory: Path) -> Path:
if ".." in directory.parts:
raise ValueError("Directory traversal is not allowed.")

base_directory = Path(os.getcwd())
base_directory = Path.cwd()

# Resolve the directory path against the base directory
resolved_directory = (base_directory / directory).resolve()
Expand Down
6 changes: 3 additions & 3 deletions nalgonda/custom_tools/write_and_save_program.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os
from pathlib import Path

from agency_swarm import BaseTool
from pydantic import Field
Expand Down Expand Up @@ -27,15 +27,15 @@ def run(self):
return "Invalid file path. Directory traversal is not allowed."

# Extract the directory path from the file name
directory_path = os.path.dirname(self.file_name)
directory_path = Path(self.file_name).parent
agency_id = "test_agency_id" # agency_id = self.context["agency_id"] # TODO: pass agency_id to all tools
directory = DATA_DIR / agency_id / directory_path

# Ensure the directory exists
directory.mkdir(parents=True, exist_ok=True)

# Construct the full path using the directory and file name
full_path = directory / os.path.basename(self.file_name)
full_path = directory / Path(self.file_name).name

# Write the file
with open(full_path, "w") as f:
Expand Down

0 comments on commit 0a61ef3

Please sign in to comment.