-
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
fix: tool name showing as function_template
in phidata
#1213
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -83,6 +85,7 @@ def function_template(*args, **kwargs) -> str: | |||
# Apply the signature and annotations to the function | |||
func.__signature__ = sig | |||
func.__annotations__ = annotations | |||
func.__setattr__("__name__", name.lower()) |
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 __setattr__
call is unsafe and could allow attribute injection. Use a direct attribute assignment with func.__name__ = name.lower()
instead.
📝 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.
func.__setattr__("__name__", name.lower()) | |
func.__name__ = name.lower() |
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.
can't assign __name__
attribute of type ToolFunction
defined by phidata
def get_actions( | ||
self, actions: t.Sequence[ActionType] | ||
) -> t.List[t.Union[Tool, Toolkit, t.Callable, t.Dict, Function]] | 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.
Return type annotation uses |
operator which requires Python 3.10+. Should use Union
from typing module for better compatibility across Python versions.
📝 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 get_actions( | |
self, actions: t.Sequence[ActionType] | |
) -> t.List[t.Union[Tool, Toolkit, t.Callable, t.Dict, Function]] | None: | |
def get_actions( | |
self, actions: t.Sequence[ActionType] | |
) -> t.Union[t.List[t.Union[Tool, Toolkit, t.Callable, t.Dict, Function]], 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.
fixed.
*, | ||
processors: t.Optional[ProcessorsType] = None, | ||
check_connected_accounts: bool = True, | ||
) -> t.List[Toolkit]: | ||
) -> t.List[t.Union[Tool, Toolkit, t.Callable, t.Dict, Function]] | 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.
Returning None in get_actions() and get_tools() could cause runtime errors if callers expect a List. Should return empty list instead of None for consistency.
📝 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.
*, | |
processors: t.Optional[ProcessorsType] = None, | |
check_connected_accounts: bool = True, | |
) -> t.List[Toolkit]: | |
) -> t.List[t.Union[Tool, Toolkit, t.Callable, t.Dict, Function]] | None: | |
) -> t.List[t.Union[Tool, Toolkit, t.Callable, t.Dict, Function]]: |
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.
not returning None anymore, will always return List[Tool | ToolKit, Callable, Function]
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.
❌ Changes requested. Reviewed everything up to d7f52f2 in 46 seconds
More details
- Looked at
60
lines of code in2
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. python/plugins/phidata/composio_phidata/toolset.py:136
- Draft comment:
The return type in the function signature includes| None
, but the docstring specifiesList[Toolkit]
. Consider updating the docstring to reflect the possibility of aNone
return value. - Reason this comment was not posted:
Marked as duplicate.
Workflow ID: wflow_IFTo5eEFw3zU20aG
Want Ellipsis to fix these issues? Tag @ellipsis-dev
in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
def get_actions(self, actions: t.Sequence[ActionType]) -> t.List[Toolkit]: | ||
def get_actions( | ||
self, actions: t.Sequence[ActionType] | ||
) -> t.List[t.Union[Tool, Toolkit, t.Callable, t.Dict, Function]] | 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 return type in the function signature includes | None
, but the docstring specifies List[Toolkit]
. Consider updating the docstring to reflect the possibility of a None
return value.
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.
not returning None anymore, will always return List[Tool | ToolKit, Callable, Function]
def get_actions(self, actions: t.Sequence[ActionType]) -> t.List[Toolkit]: | ||
def get_actions( | ||
self, actions: t.Sequence[ActionType] | ||
) -> t.List[t.Union[Tool, Toolkit, t.Callable, t.Dict, Function]] | 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 return type annotation t.List[t.Union[Tool, Toolkit, t.Callable, t.Dict, Function]] | None
indicates this method can return None, but there's no documentation or clear indication of when None would be returned. Consider:
- Adding documentation about when None is returned
- Adding runtime validation for the None case
- Updating the docstring to reflect this possibility
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.
not returning None anymore, will always return List[Tool | ToolKit, Callable, Function]
|
||
|
||
toolset = ComposioToolSet() | ||
composio_tools = toolset.get_tools( | ||
actions=[Action.GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER] | ||
) | ||
|
||
assistant = Assistant(tools=composio_tools, show_tool_calls=True) | ||
assistant = Assistant(run_id=None, tools=composio_tools, show_tool_calls=True) |
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 addition of run_id=None
parameter should be documented. Consider adding a comment explaining why this parameter is needed and what it does. This will help future maintainers understand the purpose of this change.
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.
fixed.
def get_actions(self, actions: t.Sequence[ActionType]) -> t.List[Toolkit]: | ||
def get_actions( | ||
self, actions: t.Sequence[ActionType] | ||
) -> t.List[t.Union[Tool, Toolkit, t.Callable, t.Dict, Function]] | 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.
Why this chance?
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.
assumed lowercase as mentioned in phidata's chat.
Code Review SummaryChanges Overview
Positive Aspects✅ Fixes the core issue of tool name display Suggestions for Improvement
Overall AssessmentThe changes are well-structured and solve the immediate issue while improving type safety. The code quality is good, with proper attention to backward compatibility. With the suggested documentation improvements, this PR would be ready for merge. Rating: 8/10 - Good quality changes with room for minor documentation improvements. |
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! Incremental review on 59f4d77 in 33 seconds
More details
- Looked at
36
lines of code in2
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. python/plugins/phidata/composio_phidata/toolset.py:111
- Draft comment:
The return type hint should not include| None
since the method always returns a list. Apply this change to bothget_actions
andget_tools
methods. - Reason this comment was not posted:
Comment looked like it was already resolved.
Workflow ID: wflow_21N8ZFymPk9sVQIQ
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
function_template
function_template
function_template
function_template
in phidata
Phidata toolkit was showing composio toolnames as
function_template
. Changed function signature to the lowercase enum to fix this.Important
Fix tool name display issue by setting
__name__
to lowercase infunction_template
and update return types inget_actions
andget_tools
.__name__
to lowercase infunction_template
intoolset.py
.get_actions
andget_tools
intoolset.py
to returnt.List[t.Union[Tool, Toolkit, t.Callable, t.Dict, Function]]
.Assistant
inphidata_demo.py
tofrom phi.assistant.assistant import Assistant
.This description was created by for 59f4d77. It will automatically update as commits are pushed.