-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
base: master
Are you sure you want to change the base?
feat: swarm plugin added #1218
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
"composio_core>=0.6.11,<0.7.0", | ||
"swarm @ git+https://github.com/openai/swarm.git", |
There was a problem hiding this comment.
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.
"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" |
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 |
There was a problem hiding this comment.
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.
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 |
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 |
There was a problem hiding this comment.
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.
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 |
There was a problem hiding this 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 in5
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 forload_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 inswarm_demo.py
is missing error handling for theload_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 forvalidate_tools
to manage potential validation errors gracefully. This will improve the robustness of theget_tools
method. - Reason this comment was not posted:
Confidence changes required:50%
Theget_tools
method intoolset.py
lacks error handling for thevalidate_tools
method. This could lead to unhandled exceptions if validation fails.
3. python/plugins/swarm/setup.py:27
- Draft comment:
Addpython-dotenv
toinstall_requires
to ensure the package is installed, as it is used in the code. - Reason this comment was not posted:
Confidence changes required:50%
Thesetup.py
file should specify the minimum required version for thedotenv
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 | |||
""" |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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, | ||
): |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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.
Code Review SummaryOverall, the PR adds a valuable Swarm plugin integration but has several issues that should be addressed: Major Issues:
Minor Issues:
Recommendations:
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. |
Important
Adds Swarm plugin for Composio to automate GitHub operations with type-safe instructions and provides setup and demo scripts.
ComposioToolSet
class intoolset.py
for tool management and integration with Langchain.README.md
for setting up the Swarm plugin.swarm_demo.py
for demonstrating the plugin's capabilities.setup.py
for package configuration and dependencies.This description was created by for a197037. It will automatically update as commits are pushed.