Skip to content

Commit 6cfb56e

Browse files
authored
Merge pull request #31 from AgentOps-AI/import-crew-tools
Add Tools
2 parents ccb7eec + 16bfcdf commit 6cfb56e

File tree

12 files changed

+54
-13
lines changed

12 files changed

+54
-13
lines changed

agentstack/generation/tool_generation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def add_tool(tool_name: str, path: Optional[str] = None):
2121

2222
with importlib.resources.path(f'agentstack.templates.{framework}.tools', f"{tool_name}_tool.py") as tool_file_path:
2323
os.system(tool_data['package']) # Install package
24-
shutil.copy(tool_file_path, f'{path + "/" if path else ""}src/tools/{tool_name}.py') # Move tool from package to project
24+
shutil.copy(tool_file_path, f'{path + "/" if path else ""}src/tools/{tool_name}_tool.py') # Move tool from package to project
2525
add_tool_to_tools_init(tool_data, path) # Export tool from tools dir
2626
add_tool_to_agent_definition(framework, tool_data, path)
2727
insert_code_after_tag(f'{path + "/" if path else ""}.env', '# Tools', [tool_data['env']], next_line=True) # Add env var
@@ -44,7 +44,7 @@ def add_tool_to_tools_init(tool_data: dict, path: Optional[str] = None):
4444
file_path = f'{path + "/" if path else ""}src/tools/__init__.py'
4545
tag = '# tool import'
4646
code_to_insert = [
47-
f"from {tool_data['name']}_tool import {', '.join([tool_name for tool_name in tool_data['tools']])}"
47+
f"from .{tool_data['name']}_tool import {', '.join([tool_name for tool_name in tool_data['tools']])}"
4848
]
4949
insert_code_after_tag(file_path, tag, code_to_insert, next_line=True)
5050

@@ -59,7 +59,7 @@ def add_tool_to_agent_definition(framework: str, tool_data: dict, path: Optional
5959

6060
with fileinput.input(files=filename, inplace=True) as f:
6161
for line in f:
62-
print(line.replace('tools=[', f'tools=[tools.{", tools.".join([tool_name for tool_name in tool_data["tools"]])}, '), end='')
62+
print(line.replace('tools=[', f'tools=[{"*" if tool_data.get("tools_bundled") else ""}tools.{", tools.".join([tool_name for tool_name in tool_data["tools"]])}, '), end='')
6363

6464

6565
def assert_tool_exists(tool_name: str, tools: dict):
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from crewai_tools import CodeInterpreterTool
2+
3+
code_interpreter = CodeInterpreterTool()
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from composio_crewai import ComposioToolSet, App
2+
3+
composio_tools = ComposioToolSet().get_tools(apps=[App.CODEINTERPRETER])
4+
5+
# change App.CODEINTERPRETER to be the app you want to use
6+
# For more info on tool selection, see https://docs.agentstack.sh/tools/tool/composio
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from crewai_tools import VisionTool
2+
3+
vision_tool = VisionTool()

agentstack/templates/crewai/{{cookiecutter.project_metadata.project_slug}}/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ python = ">=3.10,<=3.13"
1010
agentops = "^0.3.12"
1111
crewai = "^0.63.6"
1212
crewai-tools= "0.12.1"
13+
python-dotenv="1.0.1"
1314

1415
[project.scripts]
1516
{{cookiecutter.project_metadata.project_name}} = "{{cookiecutter.project_metadata.project_name}}.main:run"

agentstack/templates/crewai/{{cookiecutter.project_metadata.project_slug}}/src/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import sys
33
from crew import {{cookiecutter.project_metadata.project_name|replace('-', '')|replace('_', '')|capitalize}}Crew
44
import agentops
5+
from dotenv import load_dotenv
6+
load_dotenv()
57

68
agentops.init()
79

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "code_interpreter_tool",
3+
"package": "poetry add 'crewai[tools]'",
4+
"env": "",
5+
"tools": ["code_interpreter"]
6+
}

agentstack/tools/composio.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "composio",
3+
"package": "poetry add composio-crewai",
4+
"env": "COMPOSIO_API_KEY=...",
5+
"tools": ["composio_tools"],
6+
"tools_bundled": true,
7+
"cta": "!!! Composio provides 150+ tools. Additional setup is required in src/tools/composio_tool.py"
8+
}

agentstack/tools/tools.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@
1515
"name": "mem0",
1616
"url": "https://github.com/mem0ai/mem0"
1717
}],
18-
"code-gen": [{
18+
"code-execution": [{
1919
"name": "open_interpreter",
2020
"url": "https://github.com/OpenInterpreter/open-interpreter"
21+
},{
22+
"name": "code_interpreter",
23+
"url": "AgentStack default tool"
2124
}],
2225
"computer-control": [{
2326
"name": "directory_search",
@@ -27,10 +30,18 @@
2730
"url": "https://github.com/crewAIInc/crewAI-tools/tree/main/crewai_tools/tools/file_read_tool"
2831
},{
2932
"name": "ftp",
30-
"url": "AgentStack custom tool"
33+
"url": "AgentStack default tool"
3134
}],
3235
"network-protocols": [{
3336
"name": "agent_connect",
3437
"url": "https://github.com/chgaowei/AgentConnect"
38+
}],
39+
"unified-apis": [{
40+
"name": "composio",
41+
"url": "https://composio.dev/"
42+
}],
43+
"vision": [{
44+
"name": "vision",
45+
"url": "AgentStack default tool"
3546
}]
3647
}

agentstack/tools/vision.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "vision",
3+
"package": "poetry add 'crewai[tools]'",
4+
"env": "",
5+
"tools": ["vision_tool"]
6+
}

0 commit comments

Comments
 (0)