Add a tool
Attach word_count
Pass the function in tools when you create the agent.
The agent receives the function. It 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 — A list of functions. The names must match the functions you defined.
Reference: documentation