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

feat: swarm plugin added #1218

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

feat: swarm plugin added #1218

wants to merge 1 commit into from

Conversation

Prat011
Copy link
Collaborator

@Prat011 Prat011 commented Jan 22, 2025

Important

Adds Swarm plugin for Composio to automate GitHub operations with type-safe instructions and provides setup and demo scripts.

  • New Feature:
    • Adds Swarm plugin for Composio to automate GitHub operations using type-safe instructions.
    • Introduces ComposioToolSet class in toolset.py for tool management and integration with Langchain.
  • Setup and Usage:
    • Provides installation instructions in README.md for setting up the Swarm plugin.
    • Includes swarm_demo.py for demonstrating the plugin's capabilities.
  • Miscellaneous:
    • Adds setup.py for package configuration and dependencies.

This description was created by Ellipsis for a197037. It will automatically update as commits are pushed.

Copy link

vercel bot commented Jan 22, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
composio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 22, 2025 8:07am

Comment on lines +26 to +27
"composio_core>=0.6.11,<0.7.0",
"swarm @ git+https://github.com/openai/swarm.git",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The swarm package dependency is specified via git URL without pinning a specific version/commit, which could lead to breaking changes if upstream changes occur. Should pin to specific commit hash.

📝 Committable Code Suggestion

‼️ Ensure you review the code suggestion before committing it to the branch. Make sure it replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
"composio_core>=0.6.11,<0.7.0",
"swarm @ git+https://github.com/openai/swarm.git",
"composio_core>=0.6.11,<0.7.0",
"swarm @ git+https://github.com/openai/swarm.git@a1b2c3d4e5f6"

Comment on lines +15 to +20
class StructuredTool:
def __init__(self, name: str, description: str, params: t.Dict, func: t.Callable):
self.name = name
self.description = description
self.params = params
self.func = func

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The StructuredTool class is defined but its attributes are not properly typed with type hints, which could lead to runtime type errors. Add type annotations for class attributes.

📝 Committable Code Suggestion

‼️ Ensure you review the code suggestion before committing it to the branch. Make sure it replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
class StructuredTool:
def __init__(self, name: str, description: str, params: t.Dict, func: t.Callable):
self.name = name
self.description = description
self.params = params
self.func = func
class StructuredTool:
name: str
description: str
params: t.Dict
func: t.Callable
def __init__(self, name: str, description: str, params: t.Dict, func: t.Callable):
self.name = name
self.description = description
self.params = params
self.func = func

Comment on lines +103 to +119
def _wrap_tool(
self,
schema: t.Dict[str, t.Any],
entity_id: t.Optional[str] = None,
) -> StructuredTool:
"""Wraps composio tool as Langchain StructuredTool object."""
action = schema["name"]
description = schema["description"]
schema_params = schema["parameters"]
action_func = self._wrap_action(
action=action,
description=description,
schema_params=schema_params,
entity_id=entity_id,
)
tool = action_func
return tool

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _wrap_tool method returns action_func directly without using the StructuredTool class, despite declaring StructuredTool return type. This type mismatch could cause runtime errors.

📝 Committable Code Suggestion

‼️ Ensure you review the code suggestion before committing it to the branch. Make sure it replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
def _wrap_tool(
self,
schema: t.Dict[str, t.Any],
entity_id: t.Optional[str] = None,
) -> StructuredTool:
"""Wraps composio tool as Langchain StructuredTool object."""
action = schema["name"]
description = schema["description"]
schema_params = schema["parameters"]
action_func = self._wrap_action(
action=action,
description=description,
schema_params=schema_params,
entity_id=entity_id,
)
tool = action_func
return tool
def _wrap_tool(
self,
schema: t.Dict[str, t.Any],
entity_id: t.Optional[str] = None,
) -> StructuredTool:
"""Wraps composio tool as Langchain StructuredTool object."""
action = schema["name"]
description = schema["description"]
schema_params = schema["parameters"]
action_func = self._wrap_action(
action=action,
description=description,
schema_params=schema_params,
entity_id=entity_id,
)
tool = StructuredTool(
name=action,
description=description,
func=action_func,
)
return tool

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good to me! Reviewed everything up to a197037 in 2 minutes and 30 seconds

More details
  • Looked at 409 lines of code in 5 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. python/plugins/swarm/swarm_demo.py:7
  • Draft comment:
    Consider adding error handling for load_dotenv() to ensure the environment variables are loaded correctly. This will help in debugging if the .env file is missing or not configured properly.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The code in swarm_demo.py is missing error handling for the load_dotenv() function. This could lead to issues if the .env file is not present or not configured correctly.
2. python/plugins/swarm/composio_swarm/toolset.py:162
  • Draft comment:
    Consider adding error handling for validate_tools to manage potential validation errors gracefully. This will improve the robustness of the get_tools method.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The get_tools method in toolset.py lacks error handling for the validate_tools method. This could lead to unhandled exceptions if validation fails.
3. python/plugins/swarm/setup.py:27
  • Draft comment:
    Add python-dotenv to install_requires to ensure the package is installed, as it is used in the code.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The setup.py file should specify the minimum required version for the dotenv package, as it is used in the code.

Workflow ID: wflow_6GZR4tJahourC1NO


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@@ -0,0 +1,30 @@
"""
Setup configuration for Composio Pydantic AI plugin
"""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring incorrectly mentions 'Pydantic AI plugin' but this is a Swarm plugin. Please update the docstring to reflect the correct plugin type.

python_requires=">=3.10,<4",
install_requires=[
"composio_core>=0.6.11,<0.7.0",
"swarm @ git+https://github.com/openai/swarm.git",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a git URL for the swarm dependency is not recommended as it can be unstable. Consider using a specific version or at least pinning to a specific commit hash for better stability.

Composio toolset for Langchain framework.

Example:
```python
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring example shows Langchain usage but this is a Swarm plugin. Please update the example to show Swarm-specific usage instead.

description: str,
schema_params: t.Dict,
entity_id: t.Optional[str] = None,
):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _wrap_action method is missing a return type hint. Consider adding -> t.Callable to make the type signature complete.


class ComposioToolSet(
BaseComposioToolSet,
runtime="langchain",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class is inheriting from BaseComposioToolSet with runtime="langchain" but this should be runtime="swarm" for consistency.

@shreysingla11
Copy link
Collaborator

Code Review Summary

Overall, the PR adds a valuable Swarm plugin integration but has several issues that should be addressed:

Major Issues:

  1. The plugin is using Langchain runtime and examples instead of Swarm-specific ones
  2. Unstable dependency on Swarm git repository without version pinning
  3. Incorrect docstrings and examples referencing wrong frameworks

Minor Issues:

  1. Missing type hints in some methods
  2. Some documentation inconsistencies
  3. Setup.py has incorrect plugin description

Recommendations:

  1. Update runtime to "swarm" instead of "langchain"
  2. Pin Swarm dependency to specific version/commit
  3. Update docstrings and examples to be Swarm-specific
  4. Add missing type hints
  5. Fix documentation inconsistencies

The code structure and implementation are good, but these issues should be addressed before merging.

Code Quality Rating: 7/10 - Good structure but needs fixes for correctness and stability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants