-
Notifications
You must be signed in to change notification settings - Fork 194
docs(custom-tools): improve docs for creating custom tools #1791
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
Conversation
Each activity takes a `config` keyword argument that contains the configuration for the activity. The configuration can contain: | ||
|
||
- `description` (str): A plain text description of the activity. Ensure that the description is clear and concise as it will help inform the LLM of when to pick this activity. | ||
- `schema` (optional): An optional instance of `Schema` that defines the input values to the activity. This field can be omitted if the activity does not require any input values. |
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.
does not require or does not take? afaik you can have a tool with all optional params but still have a schema
"This field should be omitted if the activity does not accept any input values"
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.
Good point, I will more clearly distinguish between an optional schema and a schema with optional values.
@activity( | ||
config={ | ||
"description": "Can be used to generate random numbers", | ||
"schema": Schema( | ||
{Optional(Literal("decimals", description="Number of decimals to round the random number to")): int} | ||
{ | ||
"start": int, |
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.
Does @activity have magic that will apply the documentation description (L28-29) to the schema? If not, should we document how to provide description in the schema?
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.
Good call, will add back an example of Literal
.
@@ -21,7 +21,28 @@ Here is a simple random number generator Tool: | |||
--8<-- "docs/griptape-framework/tools/custom-tools/logs/index_2.txt" | |||
``` | |||
|
|||
Check out other [Griptape Tools](https://github.com/griptape-ai/griptape/tree/main/griptape/tools) to learn more about tool implementation details. | |||
### Tool Activities | |||
|
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.
It might be nice to explain what an "activity" is to an Agent. Not just a method with the activity decorator - but that it is a thing the agent can do.
For example:
Tool Activities
Activities are actions an Agent can perform with a various tool. They are described in natural language and are passed to the Agent when the tool is given to it. Some examples:
- "Can be used to create a random number"
- "Can be used to select a random item from a list"
Technically, each activity is a method in the tool class that's decorated with the activity
decorator.
...
I know it's described down below that each activity contains a `config` keyword with a `description` and `schema` - but we jump straight to the technical without explaining the natural language first.
@@ -32,3 +53,5 @@ To start, create a directory for your Tool inside your project. The directory mu | |||
- `requirements.txt` file with tool Python dependencies. | |||
|
|||
That's it! Import and use your Tool in your project as you would with any other Griptape 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.
Could we include an example directory structure? that would be helpful for users.
tool/
__init__.py
tool.py
requirements.txt
app.py
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.
cool - just a couple of minor notes!
d586dca
to
83884dc
Compare
83884dc
to
d1e4257
Compare
d1e4257
to
e85800e
Compare
|
||
## Tool Dependencies | ||
|
||
Each Tool can also have its own dependencies. You can specify them in a `requirements.txt` file in the tool directory and Griptape will install them during Tool execution. | ||
To start, create a directory for your Tool inside your project. The directory must have the following structure: | ||
|
||
- `tool.py` file with a tool Python class. | ||
- `requirements.txt` file with tool Python dependencies. | ||
griptape/tools/calculator/ |
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.
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.
Good catch!
e85800e
to
980d5ab
Compare
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.
nice work!
Describe your changes
Improves docs for creating custom tools. In particular, explains the nuances of the various ways to declare activity parameters.
Issue ticket number and link
Closes #1566
📚 Documentation preview 📚: https://griptape--1791.org.readthedocs.build//1791/