Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions agentstack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This it the beginning of the agentstack public API.

Methods that have been imported into this file are expected to be used by the
end user inside of their project.
end user inside their project.
"""

from typing import Callable
Expand Down Expand Up @@ -40,5 +40,4 @@ class ToolLoader:
def __getitem__(self, tool_name: str) -> list[Callable]:
return frameworks.get_tool_callables(tool_name)


tools = ToolLoader()
4 changes: 2 additions & 2 deletions agentstack/cli/run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional
from typing import Optional, List
import sys
import traceback
from pathlib import Path
Expand Down Expand Up @@ -93,7 +93,7 @@ def _import_project_module(path: Path):
return project_module


def run_project(command: str = 'run', cli_args: Optional[str] = None):
def run_project(command: str = 'run', cli_args: Optional[List[str]] = None):
"""Validate that the project is ready to run and then run it."""
verify_agentstack_project()

Expand Down
2 changes: 1 addition & 1 deletion agentstack/frameworks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def validate_project():
def add_tool(tool: ToolConfig, agent_name: str):
"""
Add a tool to the user's project.
The tool will have aready been installed in the user's application and have
The tool will have already been installed in the user's application and have
all dependencies installed. We're just handling code generation here.
"""
return get_framework_module(get_framework()).add_tool(tool, agent_name)
Expand Down
28 changes: 25 additions & 3 deletions agentstack/frameworks/crewai.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
"""
Add new tools to be used by an agent.

Tool definitions are inside of the methods marked with an `@agent` decorator.
Tool definitions are inside the methods marked with an `@agent` decorator.
The method returns a new class instance with the tools as a list of callables
under the kwarg `tools`.
"""
Expand Down Expand Up @@ -330,6 +330,24 @@
except ImportError:
raise ValidationError("Could not import `crewai`. Is this an AgentStack CrewAI project?")

# TODO: remove after agentops fixes their issue
# wrap method with agentops tool event
def wrap_method(method: Callable) -> Callable:
def wrapped_method(*args, **kwargs):
import agentops
tool_event = agentops.ToolEvent(method.__name__)
result = method(*args, **kwargs)
agentops.record(tool_event)
return result

Check warning on line 341 in agentstack/frameworks/crewai.py

View check run for this annotation

Codecov / codecov/patch

agentstack/frameworks/crewai.py#L335-L341

Added lines #L335 - L341 were not covered by tests

# Preserve all original attributes
wrapped_method.__name__ = method.__name__
wrapped_method.__doc__ = method.__doc__
wrapped_method.__module__ = method.__module__
wrapped_method.__qualname__ = method.__qualname__
wrapped_method.__annotations__ = getattr(method, '__annotations__', {})
return wrapped_method

Check warning on line 349 in agentstack/frameworks/crewai.py

View check run for this annotation

Codecov / codecov/patch

agentstack/frameworks/crewai.py#L344-L349

Added lines #L344 - L349 were not covered by tests

tool_funcs = []
tool_config = ToolConfig.from_tool_name(tool_name)
for tool_func_name in tool_config.tools:
Expand All @@ -338,6 +356,10 @@
assert callable(tool_func), f"Tool function {tool_func_name} is not callable."
assert tool_func.__doc__, f"Tool function {tool_func_name} is missing a docstring."

# apply the CrewAI tool decorator to the tool function
tool_funcs.append(_crewai_tool_decorator(tool_func))
# First wrap with agentops
agentops_wrapped = wrap_method(tool_func)

Check warning on line 360 in agentstack/frameworks/crewai.py

View check run for this annotation

Codecov / codecov/patch

agentstack/frameworks/crewai.py#L360

Added line #L360 was not covered by tests
# Then apply CrewAI decorator last so it properly inherits from BaseTool
crewai_wrapped = _crewai_tool_decorator(agentops_wrapped)
tool_funcs.append(crewai_wrapped)

Check warning on line 363 in agentstack/frameworks/crewai.py

View check run for this annotation

Codecov / codecov/patch

agentstack/frameworks/crewai.py#L362-L363

Added lines #L362 - L363 were not covered by tests

return tool_funcs
6 changes: 5 additions & 1 deletion docs/tools/tools.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ agentstack tools add
You can also specify a tool, and one or more agents to install it to:
```bash
agentstack tools add <tool_name> --agents=<agent_name1>,<agent_name2>
```
```

<Note>
Add your own tool to the AgentStack repo [here](/contributing/adding-tools)!
</Note>
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "agentstack"
version = "0.2.5"
version = "0.2.5.1"
description = "The fastest way to build robust AI agents"
authors = [
{ name="Braelyn Boynton", email="bboynton97@gmail.com" },
Expand Down
Loading