함수 호출 도구: 함수 정의

OpenAI Responses API 활용하기

James Chapman

AI Curriculum Manager, DataCamp

함수 호출 도구

 

  • 함수 호출 도구: LLM이 프로그래밍된 함수를 호출함
    • 거의 모든 작업에 만들 수 있음!
  • convert_currency()
    • amount: 금액
    • from_currency: 원화 단위
    • to_currency: 대상 통화

frankfurter.png

1 https://frankfurter.dev/
OpenAI Responses API 활용하기

함수 호출 도구

fct1.jpg

OpenAI Responses API 활용하기

함수 호출 도구

fct2.jpg

OpenAI Responses API 활용하기

함수 호출 도구

fct3.jpg

OpenAI Responses API 활용하기

함수 호출 도구

fct4.jpg

OpenAI Responses API 활용하기

함수 호출 도구

fct5.jpg

OpenAI Responses API 활용하기

함수 호출 도구

fct6.jpg

OpenAI Responses API 활용하기
def convert_currency(amount, from_currency, to_currency):

url = f"https://api.frankfurter.dev/v1/latest?base={from_currency}&symbols={to_currency}"
try: response = requests.get(url) response.raise_for_status()
data = response.json() rate = data['rates'].get(to_currency)
if rate is None: return f"Could not find exchange rate for {from_currency} to {to_currency}"
converted_amount = amount * rate return f"{amount} {from_currency} = {converted_amount:.2f} {to_currency} (Rate: {rate})"
except requests.exceptions.RequestException as e: return f"Error converting currency: {str(e)}"
OpenAI Responses API 활용하기

우리의 함수

print(convert_currency(100, "USD", "EUR"))
100 USD = 86.62 EUR (Rate: 0.86625)
OpenAI Responses API 활용하기

연습해 봅시다!

OpenAI Responses API 활용하기

Preparing Video For Download...