From f5acdb87c6f2a01c20bac0141fbc6b39acb5ae51 Mon Sep 17 00:00:00 2001 From: Braelyn Boynton Date: Wed, 6 Nov 2024 17:55:03 -0800 Subject: [PATCH 1/4] code interpreter tool --- agentstack/templates/crewai/tools/code_interpreter_tool.py | 3 +++ agentstack/tools/code_interpreter.json | 6 ++++++ pyproject.toml | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 agentstack/templates/crewai/tools/code_interpreter_tool.py create mode 100644 agentstack/tools/code_interpreter.json diff --git a/agentstack/templates/crewai/tools/code_interpreter_tool.py b/agentstack/templates/crewai/tools/code_interpreter_tool.py new file mode 100644 index 0000000..f56f649 --- /dev/null +++ b/agentstack/templates/crewai/tools/code_interpreter_tool.py @@ -0,0 +1,3 @@ +from crewai_tools import CodeInterpreterTool + +code_interpreter = CodeInterpreterTool() \ No newline at end of file diff --git a/agentstack/tools/code_interpreter.json b/agentstack/tools/code_interpreter.json new file mode 100644 index 0000000..26b6f6a --- /dev/null +++ b/agentstack/tools/code_interpreter.json @@ -0,0 +1,6 @@ +{ + "name": "code_interpreter_tool", + "package": "poetry add 'crewai[tools]'", + "env": "", + "tools": ["code_interpreter"] +} \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index cf3a58c..a0494dc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "agentstack" -version = "0.1.6" +version = "0.1.7" description = "The fastest way to build robust AI agents" authors = [ { name="Braelyn Boynton", email="bboynton97@gmail.com" } From 4465c33a7c84eb23474bf480dfe9f16332b0d8d0 Mon Sep 17 00:00:00 2001 From: Braelyn Boynton Date: Thu, 7 Nov 2024 16:38:08 -0800 Subject: [PATCH 2/4] composio and bundled_tool pattern --- agentstack/generation/tool_generation.py | 4 ++-- agentstack/templates/crewai/tools/composio_tool.py | 6 ++++++ agentstack/tools/composio.json | 8 ++++++++ agentstack/tools/tools.json | 9 ++++++++- agentstack/utils.py | 6 ++---- pyproject.toml | 3 --- 6 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 agentstack/templates/crewai/tools/composio_tool.py create mode 100644 agentstack/tools/composio.json diff --git a/agentstack/generation/tool_generation.py b/agentstack/generation/tool_generation.py index 52df7c8..6bd513b 100644 --- a/agentstack/generation/tool_generation.py +++ b/agentstack/generation/tool_generation.py @@ -21,7 +21,7 @@ def add_tool(tool_name: str, path: Optional[str] = None): with importlib.resources.path(f'agentstack.templates.{framework}.tools', f"{tool_name}_tool.py") as tool_file_path: os.system(tool_data['package']) # Install package - shutil.copy(tool_file_path, f'{path + "/" if path else ""}src/tools/{tool_name}.py') # Move tool from package to project + shutil.copy(tool_file_path, f'{path + "/" if path else ""}src/tools/{tool_name}_tool.py') # Move tool from package to project add_tool_to_tools_init(tool_data, path) # Export tool from tools dir add_tool_to_agent_definition(framework, tool_data, path) insert_code_after_tag(f'{path + "/" if path else ""}.env', '# Tools', [tool_data['env']], next_line=True) # Add env var @@ -59,7 +59,7 @@ def add_tool_to_agent_definition(framework: str, tool_data: dict, path: Optional with fileinput.input(files=filename, inplace=True) as f: for line in f: - print(line.replace('tools=[', f'tools=[tools.{", tools.".join([tool_name for tool_name in tool_data["tools"]])}, '), end='') + 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='') def assert_tool_exists(tool_name: str, tools: dict): diff --git a/agentstack/templates/crewai/tools/composio_tool.py b/agentstack/templates/crewai/tools/composio_tool.py new file mode 100644 index 0000000..197c7e0 --- /dev/null +++ b/agentstack/templates/crewai/tools/composio_tool.py @@ -0,0 +1,6 @@ +from composio_crewai import ComposioToolSet, App + +composio_tools = ComposioToolSet().get_tools(apps=[App.CODEINTERPRETER]) + +# change App.CODEINTERPRETER to be the app you want to use +# For more info on tool selection, see https://docs.agentstack.sh/tools/tool/composio diff --git a/agentstack/tools/composio.json b/agentstack/tools/composio.json new file mode 100644 index 0000000..2a80bc6 --- /dev/null +++ b/agentstack/tools/composio.json @@ -0,0 +1,8 @@ +{ + "name": "composio", + "package": "poetry add composio-crewai", + "env": "COMPOSIO_API_KEY=...", + "tools": ["composio_tools"], + "tools_bundled": true, + "cta": "!!! Composio provides 150+ tools. Additional setup is required in src/tools/composio_tool.py" +} \ No newline at end of file diff --git a/agentstack/tools/tools.json b/agentstack/tools/tools.json index 89c7af0..2b2ae0a 100644 --- a/agentstack/tools/tools.json +++ b/agentstack/tools/tools.json @@ -15,9 +15,12 @@ "name": "mem0", "url": "https://github.com/mem0ai/mem0" }], - "code-gen": [{ + "code-execution": [{ "name": "open_interpreter", "url": "https://github.com/OpenInterpreter/open-interpreter" + },{ + "name": "code_interpreter", + "url": "CrewAI tool" }], "computer-control": [{ "name": "directory_search", @@ -32,5 +35,9 @@ "network-protocols": [{ "name": "agent_connect", "url": "https://github.com/chgaowei/AgentConnect" + }], + "unified-apis": [{ + "name": "composio", + "url": "https://composio.dev/" }] } diff --git a/agentstack/utils.py b/agentstack/utils.py index 20ce480..822208d 100644 --- a/agentstack/utils.py +++ b/agentstack/utils.py @@ -1,17 +1,15 @@ from typing import Optional -import toml import os import sys import json import re +from importlib.metadata import version def get_version(): try: - with open('../pyproject.toml', 'r') as f: - pyproject_data = toml.load(f) - return pyproject_data['project']['version'] + return version('agentstack') except (KeyError, FileNotFoundError) as e: print(e) return "Unknown version" diff --git a/pyproject.toml b/pyproject.toml index a0494dc..fb91407 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,9 +25,6 @@ dependencies = [ [tool.setuptools.package-data] agentstack = ["templates/**/*"] -[project.urls] -"Homepage" = "https://github.com/AgentOps-AI/AgentStack" - [project.scripts] agentstack = "agentstack.main:main" From 7a2d7583598dcfb0e552b674aadbd47ca1a03311 Mon Sep 17 00:00:00 2001 From: Braelyn Boynton Date: Thu, 7 Nov 2024 16:46:06 -0800 Subject: [PATCH 3/4] use dotenv --- agentstack/generation/tool_generation.py | 2 +- .../pyproject.toml | 1 + .../{{cookiecutter.project_metadata.project_slug}}/src/main.py | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/agentstack/generation/tool_generation.py b/agentstack/generation/tool_generation.py index 6bd513b..c50c48b 100644 --- a/agentstack/generation/tool_generation.py +++ b/agentstack/generation/tool_generation.py @@ -44,7 +44,7 @@ def add_tool_to_tools_init(tool_data: dict, path: Optional[str] = None): file_path = f'{path + "/" if path else ""}src/tools/__init__.py' tag = '# tool import' code_to_insert = [ - f"from {tool_data['name']}_tool import {', '.join([tool_name for tool_name in tool_data['tools']])}" + f"from .{tool_data['name']}_tool import {', '.join([tool_name for tool_name in tool_data['tools']])}" ] insert_code_after_tag(file_path, tag, code_to_insert, next_line=True) diff --git a/agentstack/templates/crewai/{{cookiecutter.project_metadata.project_slug}}/pyproject.toml b/agentstack/templates/crewai/{{cookiecutter.project_metadata.project_slug}}/pyproject.toml index d75c6ca..f436ef4 100644 --- a/agentstack/templates/crewai/{{cookiecutter.project_metadata.project_slug}}/pyproject.toml +++ b/agentstack/templates/crewai/{{cookiecutter.project_metadata.project_slug}}/pyproject.toml @@ -10,6 +10,7 @@ python = ">=3.10,<=3.13" agentops = "^0.3.12" crewai = "^0.63.6" crewai-tools= "0.12.1" +python-dotenv="1.0.1" [project.scripts] {{cookiecutter.project_metadata.project_name}} = "{{cookiecutter.project_metadata.project_name}}.main:run" diff --git a/agentstack/templates/crewai/{{cookiecutter.project_metadata.project_slug}}/src/main.py b/agentstack/templates/crewai/{{cookiecutter.project_metadata.project_slug}}/src/main.py index 6dba77f..76bd059 100644 --- a/agentstack/templates/crewai/{{cookiecutter.project_metadata.project_slug}}/src/main.py +++ b/agentstack/templates/crewai/{{cookiecutter.project_metadata.project_slug}}/src/main.py @@ -2,6 +2,8 @@ import sys from crew import {{cookiecutter.project_metadata.project_name|replace('-', '')|replace('_', '')|capitalize}}Crew import agentops +from dotenv import load_dotenv +load_dotenv() agentops.init() From 16bfcdfac4f0a0bc5e0308ee46d44f95bee9696d Mon Sep 17 00:00:00 2001 From: Braelyn Boynton Date: Thu, 7 Nov 2024 18:20:36 -0800 Subject: [PATCH 4/4] vision tool --- agentstack/templates/crewai/tools/vision_tool.py | 3 +++ agentstack/tools/tools.json | 8 ++++++-- agentstack/tools/vision.json | 6 ++++++ 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 agentstack/templates/crewai/tools/vision_tool.py create mode 100644 agentstack/tools/vision.json diff --git a/agentstack/templates/crewai/tools/vision_tool.py b/agentstack/templates/crewai/tools/vision_tool.py new file mode 100644 index 0000000..927ca44 --- /dev/null +++ b/agentstack/templates/crewai/tools/vision_tool.py @@ -0,0 +1,3 @@ +from crewai_tools import VisionTool + +vision_tool = VisionTool() \ No newline at end of file diff --git a/agentstack/tools/tools.json b/agentstack/tools/tools.json index 2b2ae0a..e8216e4 100644 --- a/agentstack/tools/tools.json +++ b/agentstack/tools/tools.json @@ -20,7 +20,7 @@ "url": "https://github.com/OpenInterpreter/open-interpreter" },{ "name": "code_interpreter", - "url": "CrewAI tool" + "url": "AgentStack default tool" }], "computer-control": [{ "name": "directory_search", @@ -30,7 +30,7 @@ "url": "https://github.com/crewAIInc/crewAI-tools/tree/main/crewai_tools/tools/file_read_tool" },{ "name": "ftp", - "url": "AgentStack custom tool" + "url": "AgentStack default tool" }], "network-protocols": [{ "name": "agent_connect", @@ -39,5 +39,9 @@ "unified-apis": [{ "name": "composio", "url": "https://composio.dev/" + }], + "vision": [{ + "name": "vision", + "url": "AgentStack default tool" }] } diff --git a/agentstack/tools/vision.json b/agentstack/tools/vision.json new file mode 100644 index 0000000..2ddd0b9 --- /dev/null +++ b/agentstack/tools/vision.json @@ -0,0 +1,6 @@ +{ + "name": "vision", + "package": "poetry add 'crewai[tools]'", + "env": "", + "tools": ["vision_tool"] +} \ No newline at end of file