실전편6
제 6 강 · 첫 번째 프로덕션 API 연동 코드
模块실전편预计学习15 分钟难度
🎯 이번 강의에서 배우는 내용
- Node.js/Fetch 기반의 엔드투엔드 API 호출 구현하기
- 반환된 answers 구조와 confidence 값 올바르게 추출하기
- 비즈니스 if-else 조건문에 판정 결과 연결하기
javascript
const res = await fetch("https://api.typesafe.ai/v1/systemone", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.TYPESAFE_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "jev-latest",
state: "월간 구독료가 신용카드로 중복 결제되었습니다.",
questions: {
is_urgent: { type: "noul", instructions: "즉각적인 조치를 요구하고 있습니까?" },
department: {
type: "choice",
instructions: "어느 부서 소관입니까?",
criteria: {
billing: "결제, 환불, 청구서",
technical: "시스템 오류, 버그",
sales: "플랜 업그레이드, 견적"
}
}
}
})
});
const data = await res.json();
console.log(data.answers);📌 핵심 요약
Jev는 판정만 내리며, if-else 비즈니스 로직은 개발자가 직접 통제합니다.
学完后记得保存进度
完成状态只保存在当前浏览器,不会上传你的学习记录。