구조화된 출력의 필요성
LLM 출력을 프로그래밍적으로 처리하려면 JSON 등 구조화된 형태가 필요합니다.
Claude Tool Use로 구조화
const response = await anthropic.messages.create({
model: "claude-sonnet-4-20250514",
tools: [{
name: "extract_info",
input_schema: {
type: "object",
properties: {
name: { type: "string" },
sentiment: { type: "string", enum: ["positive", "negative", "neutral"] },
score: { type: "number", minimum: 0, maximum: 1 },
},
required: ["name", "sentiment", "score"],
},
}],
tool_choice: { type: "tool", name: "extract_info" },
messages: [{ role: "user", content: reviewText }],
});
댓글 0