Agents
Overview
An Agent is the quickest way to get started with Griptape. Agents take in tools and input directly, which the agent uses to dynamically determine whether to use a Prompt Task or Toolkit Task.
If tools are passed provided to the Agent, a Toolkit Task will be used. If no tools are provided, a Prompt Task will be used.
You can access the final output of the Agent by using the output attribute.
Toolkit Task Agent
from griptape.structures import Agent
from griptape.tools import CalculatorTool
agent = Agent(input="Calculate the following: {{ args[0] }}", tools=[CalculatorTool()])
agent.run("what's 13^7?")
print("Answer:", agent.output)
[07/23/24 10:53:41] INFO ToolkitTask 487db777bc014193ba90b061451b69a6
Input: Calculate the following: what's 13^7?
[07/23/24 10:53:42] INFO Subtask 126cefa3ac5347b88495e25af52f3268
Actions: [
{
"tag": "call_ZSCH6vNoycOgtPJH2DL2U9ji",
"name": "CalculatorTool",
"path": "calculate",
"input": {
"values": {
"expression": "13**7"
}
}
}
]
INFO Subtask 126cefa3ac5347b88495e25af52f3268
Response: 62748517
[07/23/24 10:53:43] INFO ToolkitTask 487db777bc014193ba90b061451b69a6
Output: 62,748,517
Answer: 62,748,517