mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-09 08:08:32 +00:00
add important missing parts to creating tools
This commit is contained in:
@@ -150,15 +150,20 @@ There are two main ways for one to create a CrewAI tool:
|
|||||||
|
|
||||||
```python Code
|
```python Code
|
||||||
from crewai.tools import BaseTool
|
from crewai.tools import BaseTool
|
||||||
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
|
class MyToolInput(BaseModel):
|
||||||
|
"""Input schema for MyCustomTool."""
|
||||||
|
argument: str = Field(..., description="Description of the argument.")
|
||||||
|
|
||||||
class MyCustomTool(BaseTool):
|
class MyCustomTool(BaseTool):
|
||||||
name: str = "Name of my tool"
|
name: str = "Name of my tool"
|
||||||
description: str = "Clear description for what this tool is useful for, your agent will need this information to use it."
|
description: str = "What this tool does. It's vital for effective utilization."
|
||||||
|
args_schema: Type[BaseModel] = MyToolInput
|
||||||
|
|
||||||
def _run(self, argument: str) -> str:
|
def _run(self, argument: str) -> str:
|
||||||
# Implementation goes here
|
# Your tool's logic here
|
||||||
return "Result from custom tool"
|
return "Tool's result"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Utilizing the `tool` Decorator
|
### Utilizing the `tool` Decorator
|
||||||
|
|||||||
Reference in New Issue
Block a user