Skip to content

Commit

Permalink
Prefix internal tools package to avoid confusion with the public `age…
Browse files Browse the repository at this point in the history
…ntstack.tools` package
  • Loading branch information
tcdent committed Dec 23, 2024
1 parent 29c9565 commit daf2cca
Show file tree
Hide file tree
Showing 42 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
recursive-include agentstack/templates *
recursive-include agentstack/tools *
recursive-include agentstack/_tools *
include agentstack.json .env .env.example
17 changes: 10 additions & 7 deletions agentstack/tools/__init__.py → agentstack/_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
from agentstack.utils import get_package_path, open_json_file, term_color, snake_to_camel


TOOLS_DIR: Path = get_package_path() / '_tools' # NOTE: if you change this dir, also update MANIFEST.in
TOOLS_CONFIG_FILENAME: str = 'config.json'


class ToolConfig(pydantic.BaseModel):
"""
This represents the configuration data for a tool.
Expand All @@ -28,7 +32,7 @@ class ToolConfig(pydantic.BaseModel):

@classmethod
def from_tool_name(cls, name: str) -> 'ToolConfig':
path = get_package_path() / f'tools/{name}/config.json'
path = TOOLS_DIR / name / TOOLS_CONFIG_FILENAME
if not os.path.exists(path): # TODO raise exceptions and handle message/exit in cli
print(term_color(f'No known agentstack tool: {name}', 'red'))
sys.exit(1)
Expand Down Expand Up @@ -72,7 +76,7 @@ def not_implemented(*args, **kwargs):
@property
def module_name(self) -> str:
"""Module name for the tool module."""
return f"agentstack.tools.{self.name}"
return f"agentstack._tools.{self.name}"

@property
def module(self) -> ModuleType:
Expand Down Expand Up @@ -101,14 +105,13 @@ def module(self) -> ModuleType:
def get_all_tool_paths() -> list[Path]:
"""
Get all the paths to the tool configuration files.
ie. agentstack/tools/<tool_name>/
Tools are identified by having a `config.json` file inside the tools/<tool_name> directory.
ie. agentstack/_tools/<tool_name>/
Tools are identified by having a `config.json` file inside the _tools/<tool_name> directory.
"""
paths = []
tools_dir = get_package_path() / 'tools'
for tool_dir in tools_dir.iterdir():
for tool_dir in TOOLS_DIR.iterdir():
if tool_dir.is_dir():
config_path = tool_dir / 'config.json'
config_path = tool_dir / TOOLS_CONFIG_FILENAME
if config_path.exists():
paths.append(tool_dir)
return paths
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion agentstack/cli/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import inquirer
from agentstack.utils import term_color
from agentstack import generation
from agentstack.tools import get_all_tools
from agentstack._tools import get_all_tools
from agentstack.agents import get_all_agents


Expand Down
2 changes: 1 addition & 1 deletion agentstack/frameworks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from agentstack import conf
from agentstack.exceptions import ValidationError
from agentstack.utils import get_framework
from agentstack.tools import ToolConfig
from agentstack._tools import ToolConfig
from agentstack.agents import AgentConfig
from agentstack.tasks import TaskConfig

Expand Down
2 changes: 1 addition & 1 deletion agentstack/frameworks/crewai.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import ast
from agentstack import conf
from agentstack.exceptions import ValidationError
from agentstack.tools import ToolConfig
from agentstack._tools import ToolConfig
from agentstack.tasks import TaskConfig
from agentstack.agents import AgentConfig
from agentstack.generation import asttools
Expand Down
2 changes: 1 addition & 1 deletion agentstack/generation/tool_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from agentstack import frameworks
from agentstack import packaging
from agentstack.utils import term_color
from agentstack.tools import ToolConfig
from agentstack._tools import ToolConfig
from agentstack.generation.files import EnvFile


Expand Down
4 changes: 2 additions & 2 deletions tests/test_cli_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from parameterized import parameterized
from pathlib import Path
import shutil
from agentstack.tools import get_all_tool_names
from agentstack._tools import get_all_tool_names

BASE_PATH = Path(__file__).parent
CLI_ENTRY = [
Expand Down Expand Up @@ -35,7 +35,7 @@ def test_add_tool(self, tool_name):
result = self._run_cli('init', f"{tool_name}_project")
self.assertEqual(result.returncode, 0)
os.chdir(self.project_dir / f"{tool_name}_project")
result = self._run_cli('generate', 'agent', 'test_agent', '--llm', 'opeenai/gpt-4o')
result = self._run_cli('generate', 'agent', 'test_agent', '--llm', 'openai/gpt-4o')
self.assertEqual(result.returncode, 0)
result = self._run_cli('generate', 'task', 'test_task')
self.assertEqual(result.returncode, 0)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_frameworks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from agentstack.conf import ConfigFile, set_path
from agentstack.exceptions import ValidationError
from agentstack import frameworks
from agentstack.tools import ToolConfig
from agentstack._tools import ToolConfig

BASE_PATH = Path(__file__).parent

Expand Down
2 changes: 1 addition & 1 deletion tests/test_generation_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from agentstack.conf import ConfigFile, set_path
from agentstack import frameworks
from agentstack.tools import get_all_tools, ToolConfig
from agentstack._tools import get_all_tools, ToolConfig
from agentstack.generation.tool_generation import add_tool, remove_tool


Expand Down
2 changes: 1 addition & 1 deletion tests/test_tool_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
import unittest
from pathlib import Path
from agentstack.tools import ToolConfig, get_all_tool_paths, get_all_tool_names
from agentstack._tools import ToolConfig, get_all_tool_paths, get_all_tool_names

BASE_PATH = Path(__file__).parent

Expand Down

0 comments on commit daf2cca

Please sign in to comment.