# ➌ 응답 유형 확인하기
for item in response.output:
# Function Call 요청 확인
if item.type == "function_call":
print("\n[Function Call 요청 감지]")
print(f" - 호출 함수: {item.name}")
print(f" - 인수: {item.arguments}")
# 일반 텍스트 응답 확인
elif item.type == "message":
print("\n[일반 텍스트 응답 감지]")
for content in item.content:
if content.type == "output_text":
print(content.text)
# 실행
try:
# Tool Use가 필요한 질문
check_for_tool_call("오늘 서울 날씨가 어때?")
# Tool Use가 필요 없는 질문
check_for_tool_call("TCP와 UDP 차이를 설명해줘.")
except Exception as e:
print(f"\n[오류] API 호출 중 문제 발생: {e}")