Agents 퀵스타트 — 여러 공급자로 에이전트 만들기

Agents 퀵스타트 — 여러 공급자로 에이전트 만들기

AISuite는 채팅뿐 아니라 에이전트도 같은 표준 인터페이스로 만들어요. 에이전트를 정의하고, 여러 공급자의 도구 호출을 이어서 처리하는 흐름을 볼게요.

출처: https://github.com/andrewyng/aisuite/blob/main/docs/agents-quickstart.md

import aisuite as ai
from aisuite.agents import Tool, Agent

# 도구 정의
def get_weather(city: str) -> str:
    return f"The weather in {city} is sunny."

tools = [Tool.from_function(get_weather)]

# 에이전트 생성
agent = Agent(model="openai:gpt-4o", tools=tools, system_prompt="You are a helpful agent.")
result = agent.run("What is the weather in Berlin?")
print(result)
  • Tool.from_function(fn): 파이썬 함수를 도구로 감싸요.
  • Agent(model=..., tools=..., system_prompt=...): 에이전트를 정의해요.
  • agent.run(...): 대화와 도구 호출 루프를 끝까지 돌리고 결과를 돌려줘요.

모델 문자열만 바꾸면 Anthropic, Mistral, Groq 등 공급자에 걸쳐 같은 에이전트 로직을 재사용할 수 있어요.

더 알아보기