Agents
Adapted from the Griptape AI Framework documentation.
Overview
An Agent is the quickest way to get started with Gen AI Builder. Agents take in tools and input directly, which the agent uses to add a Prompt Task.
You can access the final output of the Agent by using the output attribute.
Agent Tools
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)
[02/27/25 20:27:58] INFO PromptTask b01ef6f2df44408ab55cc6c9f4e8bc1c Input: Calculate the following: what's 13^7? [02/27/25 20:27:59] INFO Subtask 55f186e0ce5040f6a8e91f6bd2f75f77 Actions: [ { "tag": "call_EkyljA8FEDA2R8TZktNu8nAs", "name": "CalculatorTool", "path": "calculate", "input": { "values": { "expression": "13**7" } } } ] INFO Subtask 55f186e0ce5040f6a8e91f6bd2f75f77 Response: 62748517 [02/27/25 20:28:00] INFO PromptTask b01ef6f2df44408ab55cc6c9f4e8bc1c Output: The result of \(13^7\) is 62,748,517. Answer: The result of \(13^7\) is 62,748,517.
Agent Input
from griptape.structures import Agent agent = Agent( input="Write me a {{ args[0] }} about {{ args[1] }} and {{ args[2] }}", ) agent.run("Haiku", "Skateboards", "Programming")
[02/27/25 20:27:49] INFO PromptTask 883015011f22460082f152115126353b Input: Write me a Haiku about Skateboards and Programming [02/27/25 20:27:50] INFO PromptTask 883015011f22460082f152115126353b Output: Wheels spin on pavement, Code flows like a river's path— Balance in both worlds.
- On this page
- Overview
← Prev
token_counter
↑ Up
Gen AI Builder: A Python Framework for Building Generative AI Applications
Next →
Pipelines
Could this page be better? Report a problem or suggest an addition!