C.W.K.
Stream
Lesson 01 of 07 · published

Tool Definition Schema — JSON Schema 위 contract

~22 min · tools, schema, function-calling

Level 0Tokenizer
0 XP0/54 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

Tool 의 parameters 는 JSON Schema 의 subset — type, properties, required, enum, description. Strict mode 에선 모델의 호출이 schema 와 정확히 매칭. Schema 가 authoritative shape.

두 shape, 한 작업

Responses 는 tool object 의 top level 에 name, parameters. Chat Completions 는 nested function sub-object. Schema body 는 동일 — 감싸는 wrapper 만 달라. 두 shape 섞으면 silent break.

모델이 보는 것

모델은 name, description, parameters JSON Schema (각 property 의 description, enum 포함) 를 봐. Handler 구현은 안 봐. 그러니까 schema 가 contract 의 전부 — schema 로 표현 못 하는 동작은 description 에 자연어로 명시.

Per-property description 도 모델이 읽음

parameters.properties.units.description: 'temperature unit, celsius or fahrenheit' 는 모델이 routing 결정에 사용. 'units: required' 같은 건 X — schema 가 이미 required.

Code

Tool 정의 (Responses shape)·python
tools = [{
    "type": "function",
    "name": "get_weather",             # top-level name
    "description": "Get current weather for a location.",
    "parameters": {
        "type": "object",
        "properties": {
            "location": {
                "type": "string",
                "description": "City and country, e.g. 'London, UK'"
            },
            "units": {
                "type": ["string", "null"],
                "enum": ["celsius", "fahrenheit"],
                "description": "Temperature unit"
            }
        },
        "required": ["location", "units"],
        "additionalProperties": False
    },
    "strict": True,
}]
Tool 정의 (Chat Completions shape)·python
tools = [{
    "type": "function",
    "function": {                      # nested under "function"
        "name": "get_weather",
        "description": "Get current weather for a location.",
        "parameters": { ... },
        "strict": True,
    }
}]

External links

Exercise

send_email(to, subject, body, cc[]?, bcc[]?) tool 정의 — Responses 와 Chat Completions 둘 다 한 번씩. 둘 다 같은 handler 호출 검증.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.