Anthropic 도구 입력 예시

Anthropic 도구 입력 예시 (Tool Input Examples)

유효한 도구 입력의 구체적인 예시를 제공하면, Claude가 도구를 더 효과적으로 사용하는 방법을 이해하는 데 도움이 돼요. 특히 중첩 객체, 선택적 파라미터, 형식에 민감한 입력이 있는 복잡한 도구에서 유용해요.

참고: 도구 입력 예시는 베타 기능이에요. LiteLLM은 input_examples 필드가 있는 도구를 자동으로 감지하고, 프로바이더에 따라 적절한 베타 헤더를 추가해요:

  • Anthropic API & Microsoft Foundry: advanced-tool-use-2025-11-20
  • Amazon Bedrock: advanced-tool-use-2025-11-20 (Claude Opus 4.5만)
  • Google Cloud Vertex AI: 지원하지 않음

베타 헤더를 수동으로 지정할 필요는 없어요 — LiteLLM이 자동으로 처리해요.

출처: 문서

본문

입력 예시를 언제 쓰나요? (When to Use Input Examples)

입력 예시는 다음 경우에 가장 유용해요.

  • 복잡한 중첩 객체: 깊이 중첩된 파라미터 구조를 가진 도구
  • 선택적 파라미터: 선택적 파라미터를 언제 포함해야 하는지 보여주기
  • 형식에 민감한 입력: 기대되는 형식(날짜, 주소 등)을 보여주기
  • 열거형(Enum) 값: 컨텍스트 안에서 유효한 enum 선택지를 보여주기
  • 엣지 케이스: 특수한 경우를 처리하는 방법 보여주기

팁: 설명을 먼저 우선하세요! 명확하고 상세한 도구 설명이 예시보다 더 중요해요. 설명만으로 부족할 수 있는 복잡한 도구에서 input_examples를 보조로 사용하세요.

빠른 시작 (Quick Start)

도구 정의에 input_examples 필드를 추가하고 예시 입력 객체의 배열을 넣어요.

import litellm
response = litellm.completion(
    model="anthropic/claude-sonnet-4-5-20250929",
    messages=[
        {"role": "user", "content": "What's the weather like in San Francisco?"}
    ],
    tools=[
        {
            "type": "function",
            "function": {
                "name": "get_weather",
                "description": "Get the current weather in a given location",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "location": {
                            "type": "string",
                            "description": "The city and state, e.g. San Francisco, CA"
                        },
                        "unit": {
                            "type": "string",
                            "enum": ["celsius", "fahrenheit"],
                            "description": "The unit of temperature"
                        }
                    },
                    "required": ["location"]
                }
            },
            "input_examples": [
                {
                    "location": "San Francisco, CA",
                    "unit": "fahrenheit"
                },
                {
                    "location": "Tokyo, Japan",
                    "unit": "celsius"
                },
                {
                    "location": "New York, NY"  # 'unit' is optional
                }
            ]
        }
    ]
)
print(response)

동작 원리 (How It Works)

input_examples를 제공하면:

  1. LiteLLM은 해당 필드가 있는 도구를 자동으로 감지하고, 프로바이더에 맞는 베타 헤더를 추가해요.

더 알아보기 (Learn more)