Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add local apps logo #528

Merged
merged 5 commits into from
Sep 3, 2024
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
12 changes: 9 additions & 3 deletions python/composio/tools/base/abs.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ class _Attributes:
description: str
"""Description string."""

logo: str
"""URL for the resource logo."""


class _Request(t.Generic[ModelType]):
"""Request util."""
Expand Down Expand Up @@ -389,6 +392,9 @@ def setup_children(obj: t.Type["Tool"]) -> None:
obj._actions[action.enum] = action # pylint: disable=protected-access
action_registry[obj.gid][action.enum] = action # type: ignore

if hasattr(obj, "logo"):
setattr(action, "logo", getattr(obj, "logo"))

if not hasattr(obj, "triggers"):
return

Expand All @@ -401,6 +407,9 @@ def setup_children(obj: t.Type["Tool"]) -> None:
obj._triggers[trigger.enum] = trigger # type: ignore # pylint: disable=protected-access
trigger_registry[obj.gid][trigger.enum] = trigger # type: ignore

if hasattr(obj, "logo"):
setattr(trigger, "logo", getattr(obj, "logo"))


class Tool(WithLogger, _Attributes):
"""Tool abstraction."""
Expand All @@ -411,9 +420,6 @@ class Tool(WithLogger, _Attributes):
file: Path
"""Path to module file."""

name: str
"""Tool name."""

_schema: t.Optional[t.Dict] = None
"""Schema for the app."""

Expand Down
11 changes: 11 additions & 0 deletions python/composio/tools/base/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
Action,
ActionRequest,
ActionResponse,
InvalidClassDefinition,
Tool,
ToolBuilder,
)
Expand Down Expand Up @@ -79,9 +80,16 @@ def __init__( # pylint: disable=self-cls-assignment,unused-argument
ToolBuilder.setup_children(
obj=cls, # type: ignore
)

if autoload:
t.cast(t.Type["Tool"], cls).register() # type: ignore

if not hasattr(cls, "logo"):
raise InvalidClassDefinition(f"Please provide logo URL for {name}")

if "local" not in cls.tags: # type: ignore
cls.tags.append("local") # type: ignore


class LocalToolMixin(Tool):
@classmethod
Expand Down Expand Up @@ -196,6 +204,9 @@ class LocalTool(LocalToolMixin, metaclass=LocalToolMeta):
gid = "local"
"""Group ID for this tool."""

tags: t.List[str] = ["local"]
"""Tags for this app."""

@classmethod
@abstractmethod
def actions(cls) -> t.List[t.Type[LocalAction]]:
Expand Down
2 changes: 1 addition & 1 deletion python/composio/tools/base/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def execute(request: BaseModel, metadata: t.Dict) -> BaseModel:
if isinstance(response, BaseModel):
return response

rname = returns[0] if returns is not None else "return"
rname = returns[0] if returns is not None else "result"
return ResponseSchema(**{rname: response})

execute.__doc__ = header
Expand Down
2 changes: 2 additions & 0 deletions python/composio/tools/local/browsertool/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
class BrowserTool(LocalTool, autoload=True):
"""Browser tool for local usage."""

logo = "https://raw.githubusercontent.com/ComposioHQ/composio/master/python/docs/imgs/logos/browsertool.png"

@classmethod
def actions(cls) -> t.List[t.Type[LocalAction]]:
"""Return the list of actions."""
Expand Down
2 changes: 2 additions & 0 deletions python/composio/tools/local/codeformat/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
class CodeFormatTool(LocalTool, autoload=True):
"""Code Format tool."""

logo = "https://raw.githubusercontent.com/ComposioHQ/composio/master/python/docs/imgs/logos/codeformat.png"

@classmethod
def actions(cls) -> t.List[t.Type[LocalAction]]:
"""Return the list of actions."""
Expand Down
2 changes: 2 additions & 0 deletions python/composio/tools/local/codegrep/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
class CodeGrepTool(LocalTool, autoload=True):
"""Code Grep tool."""

logo = "https://raw.githubusercontent.com/ComposioHQ/composio/master/python/docs/imgs/logos/codegrep.png"

@classmethod
def actions(cls) -> t.List[t.Type[LocalAction]]:
"""Return the list of actions."""
Expand Down
2 changes: 2 additions & 0 deletions python/composio/tools/local/codeindex/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
class CodeIndexTool(LocalTool, autoload=True):
"""Code index tool."""

logo = "https://raw.githubusercontent.com/ComposioHQ/composio/master/python/docs/imgs/logos/codemap.png"

@classmethod
def actions(cls) -> t.List[t.Type[LocalAction]]:
"""Return the list of actions."""
Expand Down
2 changes: 2 additions & 0 deletions python/composio/tools/local/codemap/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
class CodeMapTool(LocalTool, autoload=True):
"""Code Map tool."""

logo = "https://raw.githubusercontent.com/ComposioHQ/composio/master/python/docs/imgs/logos/codemap.png"

@classmethod
def actions(cls) -> t.List[t.Type[LocalAction]]:
"""Return the list of actions."""
Expand Down
2 changes: 2 additions & 0 deletions python/composio/tools/local/embedtool/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class EmbedTool(LocalTool, autoload=True):
This tool is useful in embedding images and finding images with text
"""

logo = "https://raw.githubusercontent.com/ComposioHQ/composio/master/python/docs/imgs/logos/embedtool.png"

@classmethod
def actions(cls) -> t.List[t.Type[LocalAction]]:
return [CreateImageVectorStore, QueryImageVectorStore]
2 changes: 2 additions & 0 deletions python/composio/tools/local/filetool/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
class Filetool(LocalTool, autoload=True):
"""File I/O tool."""

logo = "https://raw.githubusercontent.com/ComposioHQ/composio/master/python/docs/imgs/logos/filetool.png"

@classmethod
def actions(cls) -> t.List[t.Type[LocalAction]]:
"""Return the list of actions."""
Expand Down
2 changes: 2 additions & 0 deletions python/composio/tools/local/greptile/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
class Greptile(LocalTool, autoload=True):
"""Code understanding tool. Index Code and answer questions about it."""

logo = "https://raw.githubusercontent.com/ComposioHQ/composio/master/python/docs/imgs/logos/greptile.png"

@classmethod
def actions(cls) -> list[t.Type[LocalAction]]:
return [CodeQuery]
2 changes: 2 additions & 0 deletions python/composio/tools/local/imageanalyser/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
class ImageAnalyser(LocalTool, autoload=True):
"""Image Analyser tool for local usage."""

logo = "https://raw.githubusercontent.com/ComposioHQ/composio/master/python/docs/imgs/logos/imageanalyser.png"

@classmethod
def actions(cls) -> t.List[t.Type[LocalAction]]:
"""Return the list of actions."""
Expand Down
2 changes: 2 additions & 0 deletions python/composio/tools/local/mathematical/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
class Mathematical(LocalTool, autoload=True):
"""Mathematical Tools for LLM"""

logo = "https://raw.githubusercontent.com/ComposioHQ/composio/master/python/docs/imgs/logos/mathematical.png"

@classmethod
def actions(cls) -> list[t.Type[LocalAction]]:
return [Calculator]
2 changes: 2 additions & 0 deletions python/composio/tools/local/ragtool/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
class Ragtool(LocalTool, autoload=True):
"""Rag Tool"""

logo = "https://raw.githubusercontent.com/ComposioHQ/composio/master/python/docs/imgs/logos/Ragtool.png"

@classmethod
def actions(cls) -> list[t.Type[LocalAction]]:
return [RagToolQuery, AddContentToRagTool]
2 changes: 2 additions & 0 deletions python/composio/tools/local/shelltool/git_cmds/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
class Git(LocalTool, autoload=True):
"""Command manager tool for workspace"""

logo = "https://raw.githubusercontent.com/ComposioHQ/composio/master/python/docs/imgs/logos/shelltool.png"

@classmethod
def actions(cls) -> t.List[t.Type[LocalAction]]:
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
class HistoryFetcher(LocalTool, autoload=True):
"""Local workspace tool which can maintain history across commands"""

logo = "https://raw.githubusercontent.com/ComposioHQ/composio/master/python/docs/imgs/logos/shelltool.png"

@classmethod
def actions(cls) -> list[t.Type[LocalAction]]:
return [GetWorkspaceHistory]
2 changes: 2 additions & 0 deletions python/composio/tools/local/shelltool/shell_exec/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
class Shelltool(LocalTool, autoload=True):
"""Tool for executing shell commands."""

logo = "https://raw.githubusercontent.com/ComposioHQ/composio/master/python/docs/imgs/logos/shelltool.png"

@classmethod
def actions(cls) -> t.List[t.Type[LocalAction]]:
"""Returns list of actions."""
Expand Down
2 changes: 2 additions & 0 deletions python/composio/tools/local/shelltool/workspace/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class WorkspaceTool(LocalTool, autoload=True):
this is a tool for creating local workspace
"""

logo = "https://raw.githubusercontent.com/ComposioHQ/composio/master/python/docs/imgs/logos/shelltool.png"

@classmethod
def actions(cls) -> list[t.Type[LocalAction]]:
return [WorkspaceStatusAction]
2 changes: 2 additions & 0 deletions python/composio/tools/local/spidertool/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
class Spidertool(LocalTool, autoload=True):
"""Spider Tools"""

logo = "https://raw.githubusercontent.com/ComposioHQ/composio/master/python/docs/imgs/logos/spidertool.png"

@classmethod
def actions(cls) -> list[t.Type[LocalAction]]:
return [Scrape, Crawl]
2 changes: 2 additions & 0 deletions python/composio/tools/local/sqltool/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class Sqltool(LocalTool, autoload=True):
This class enables us to execute sql queries in a database
"""

logo = "https://raw.githubusercontent.com/ComposioHQ/composio/master/python/docs/imgs/logos/sqltool.png"

@classmethod
def actions(cls) -> list[Type[LocalAction]]:
return [SqlQuery]
2 changes: 2 additions & 0 deletions python/composio/tools/local/system/system_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class SystemTools(LocalTool, autoload=True):
System Tools for LLM
"""

logo = "https://raw.githubusercontent.com/ComposioHQ/composio/master/python/docs/imgs/logos/systemtool.png"

@classmethod
def actions(cls) -> list[t.Type[LocalAction]]:
return [ScreenCapture, Notify]
2 changes: 2 additions & 0 deletions python/composio/tools/local/webtool/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
class Webtool(LocalTool, autoload=True):
"""Web Tools"""

logo = "https://raw.githubusercontent.com/ComposioHQ/composio/master/python/docs/imgs/logos/webtool.png"

@classmethod
def actions(cls) -> list[t.Type[LocalAction]]:
return [ScrapeWebsiteContent, ScrapeWebsiteElement]
2 changes: 2 additions & 0 deletions python/composio/tools/local/zep/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
class Zeptool(LocalTool, autoload=True):
"""Tool definition for zep"""

logo = "https://raw.githubusercontent.com/ComposioHQ/composio/master/python/docs/imgs/logos/zep.png"

@classmethod
def actions(cls) -> t.List[t.Type[LocalAction]]:
"""Get zep actions."""
Expand Down
Binary file added python/docs/imgs/logos/Ragtool.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added python/docs/imgs/logos/browsertool.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added python/docs/imgs/logos/clickup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added python/docs/imgs/logos/codeformat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added python/docs/imgs/logos/codegrep.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added python/docs/imgs/logos/codemap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added python/docs/imgs/logos/embedtool.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added python/docs/imgs/logos/filetool.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added python/docs/imgs/logos/greptile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added python/docs/imgs/logos/imageanalyser.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added python/docs/imgs/logos/mathematical.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added python/docs/imgs/logos/shelltool.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added python/docs/imgs/logos/spidertool.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added python/docs/imgs/logos/sqltool.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added python/docs/imgs/logos/systemtool.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added python/docs/imgs/logos/webtool.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added python/docs/imgs/logos/zep.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions python/tests/test_client/test_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def execute(


class SomeLocalTool(LocalTool, autoload=True):
logo = ""

@classmethod
def actions(cls) -> List[type[LocalAction]]:
return [SomeLocalAction]
Expand Down
8 changes: 8 additions & 0 deletions python/tests/test_tools/test_base/test_abs.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def test_missing_methods(self) -> None:
):

class SomeTool(Tool):
logo = ""

def execute(self, request: dict, metadata: Dict) -> dict: # type: ignore
return {}

Expand All @@ -81,13 +83,17 @@ def test_invalid_methods(self) -> None:
):

class SomeTool(Tool):
logo = ""

def actions(self) -> list: # type: ignore
return []

ToolBuilder.validate(obj=SomeTool, name="SomeTool", methods=("actions",))

def test_metadata(self) -> None:
class SomeTool(Tool):
logo = ""

@classmethod
def actions(cls) -> list:
return []
Expand All @@ -112,6 +118,8 @@ def execute(self, request: Request, metadata: Dict) -> Response:
return Response()

class SomeTool(Tool):
logo = ""

@classmethod
def actions(cls) -> list:
return [SomeAction]
Expand Down
2 changes: 2 additions & 0 deletions python/tests/test_tools/test_base/test_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ def execute(self, request: Request, metadata: Dict) -> Response:


class SomeTool(LocalTool, autoload=True):
logo = ""

@classmethod
def actions(cls) -> List[type[LocalAction]]:
return [SomeAction]
Expand Down
Loading