-
Notifications
You must be signed in to change notification settings - Fork 3k
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
refactor: Move BaseTool to main package and centralize tool description generation #1514
Conversation
src/crewai/tools/base_tool.py
Outdated
@classmethod | ||
def from_langchain(cls, tool: StructuredTool) -> "BaseTool": | ||
if cls == Tool: | ||
return cls( |
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.
I was getting some errors with func not existing on cls
.
Let's change this to something like this unless you have another suggestion:
@classmethod
def from_langchain(cls, tool: StructuredTool) -> "BaseTool":
if cls == Tool:
if tool.func is None:
raise ValueError("StructuredTool must have a callable 'func'")
return Tool(
name=tool.name,
description=tool.description,
args_schema=tool.args_schema,
func=tool.func,
)
raise NotImplementedError(f"from_langchain not implemented for {cls.__name__}")
```
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.
This is an amazing PR @c0dezli !!!
Thank you so much. There was only one linting on the from_langchain
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.
sweet! just made the change. thanks for reviewing!
PR for crewAI-tools linked here: crewAIInc/crewAI-tools#119 |
Description:
Problem
Currently, we have:
BaseTool
definition in crewai-tools package, which should focus on tool implementations rather than core definitions_render_text_description_and_args()
_render()
_generate_description()
Proposed Changes
Move
BaseTool
class from crewai-tools to the main crewai packageCreate a centralized tool description generator in the moved base_tool.py:
_render_text_description_and_args()
in agent.py_render()
in tool_usage.pyBenefits
Breaking Changes
Migration Guide
For users importing from crewai-tools:
Related Issues: #1511