시작하기무료로 시작하기

OpenAI 도구 정의 만들기

여러분은 OpenTimezone API를 사용해 시간대 간 날짜-시간을 변환하는 convert_timezone() 함수를 만들었습니다. 이제 LLM이 이 함수를 어떻게 사용할지 이해할 수 있도록 OpenAI 형식의 도구 정의를 작성해야 합니다. 이 도구 정의는 함수의 목적, 매개변수, 요구 사항을 설명하는 모델용 설명서 역할을 합니다.

이 연습은 강의의 일부입니다

OpenAI Responses API 활용하기

강의 보기

연습 안내

  • "function" 유형의 도구를 "convert_timezone"라는 이름으로 정의하세요.
  • 함수의 세 가지 매개변수 "date_time", "from_timezone", "to_timezone" 각각에 대한 정의를 작성하세요.
  • 세 매개변수 모두가 도구에서 필수(required)로 표시되도록 하세요.

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

tools = [
    {
        # Define a function tool called convert_timezone
        "type": "____",
        "name": "____",
        "description": "Convert a datetime from one timezone to another using the OpenTimezone API.",
        "parameters": {
            "type": "object",
            # Define the parameter names, types, and descriptions
            "properties": {
                "____": {
                    "type": "____",
                    "description": "The datetime string in ISO format (e.g., '2025-01-20T14:30:00')"
                },
                "____": {
                    "type": "____",
                    "description": "The source timezone (e.g., 'America/New_York', 'Asia/Tokyo')"
                },
                "____": {
                    "type": "____",
                    "description": "The target timezone (e.g., 'Europe/London', 'Australia/Sydney')"
                }
            },
            # Ensure that all three parameters are required
            "____": ["date_time", "from_timezone", "to_timezone"],
            "additionalProperties": False
        }
    }
]
코드 편집 및 실행