Griptape 에이전트 — 도구와 입력을 받는 Agent 구조
Griptape 에이전트
Griptape에서 **에이전트(Agent)**는 가장 빠르게 시작할 수 있는 구조예요. 에이전트는 도구(tools)와 입력(input)을 직접 받아서 프롬프트 태스크를 만들고, 실행 결과는 output 속성으로 얻어요.
출처: https://docs.griptape.ai/latest/griptape-framework/structures/agents/
도구가 있는 에이전트
CalculatorTool을 붙인 에이전트에 계산 질문을 주면, 에이전트가 도구를 호출해 결과를 계산해 반환해요.
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)
Answer: The result of \(13^7\) is 62,748,517.
13의 7승을 계산하는 동안 에이전트는 CalculatorTool의 calculate 경로에 {"expression": "13**7"}을 넘겨 도구를 호출하고, 그 결과를 얻어 자연어로 답해요.
입력 템플릿이 있는 에이전트
입력에 {{ args[0] }} 같은 템플릿을 쓰면 실행 시 여러 인자를 넘길 수 있어요.
from griptape.structures import Agent
agent = Agent(
input="Write me a {{ args[0] }} about {{ args[1] }} and {{ args[2] }}",
)
agent.run("Haiku", "Skateboards", "Programming")
Wheels spin on pavement,
Code flows like a river's path—
Balance in both worlds.
에이전트는 세 인자를 템플릿에 채워 스케이트보드와 프로그래밍에 대한 하이쿠를 만들어요.