Tools
Count the words
A tool is a small recipe the agent may run. def names the recipe. The quoted line under the name says what it is for.
This first example runs the recipe by itself, so you can see the number.
Example
def word_count(text: str) -> str:
"""Count the words in text."""
return str(len(text.split()))
print(word_count("praison agents university"))Example explained
- def — Starts the recipe.
- docstring — The quoted description the agent reads.
Give the recipe to an agent
tools is the list of recipes. The agent can call word_count while it answers.
Example
from praisonai import Agent
def word_count(text: str) -> str:
"""Count the words in text."""
return str(len(text.split()))
agent = Agent(
name="Counter",
instructions="Use the word_count tool.",
tools=[word_count],
)
print(agent.start("How many words are in: praison agents university"))Example explained
- tools — Where the recipe is attached.
Reference: documentation