C.W.K.
Stream
Lesson 05 of 05 · published

비교 매트릭스

~20 min · comparison, matrix, decision, portability

Level 0호기심 많은 독자
0 XP0/48 lessons0/14 achievements
0/100 XP to next level100 XP to go0% complete

Provider 셋 envelope 을 나란히 깔면 매트릭스 짧아져. 차이 대부분이 cosmetic, 몇 개만 진짜.

ConceptOpenAIAnthropicGemini
Tool 리스트 필드toolstoolstools (config 안)
Schema 필드parametersinput_schemaparameters (Schema object)
Args 타입JSON 문자열dictdict
Tool choice"auto"|"required"|spectype: "auto"|"any"|"tool"FunctionCallingMode enum
Stop 신호response.completed + output[].typestop_reasonfunction_call part 유무
Streaming tool argsDeltaDelta (per content block)한 번에
Pre-built native toolweb_search, code_interpreter, file_searchcomputer_use, text_editor, bashcode_execution, google_search
MCP integrationApps SDK 경유Messages API mcp_servers 경유Vertex AI tool config 경유

차이가 cosmetic 아니고 진짜인 4 칸: args 타입 (parse vs use), streaming 동작 (delta vs 한 번에), pre-built tool (각 provider 가 unique offering), MCP integration 모양. Cosmetic 한 거엔 얇은 번역 layer; 진짜인 거엔 provider-specific 코드 받아들여.

유혹은 셋 다 같은 척 거대 abstraction 짓는 거. 가능한 한 오래 저항해. '메시지 + tool 보내고 tool call 받고 결과 보냄' 모양이 이미 작은 abstraction — over-abstract 하면 진짜 차이 가리고 아무도 maintain 안 하는 SDK 클론 만들어.

Code

작은 portability shim — 진짜 필요한 것만·python
def normalize_tool_calls(provider, response):
    if provider == "openai":
        return [(item.name, json.loads(item.arguments)) for item in response.output if item.type == "function_call"]
    if provider == "anthropic":
        return [(b.name, b.input) for b in response.content if b.type == "tool_use"]
    if provider == "gemini":
        return [(p.function_call.name, dict(p.function_call.args))
                for p in response.candidates[0].content.parts
                if p.function_call]
    raise ValueError(f"Unknown provider {provider!r}")

External links

Exercise

위 매트릭스를 4 '진짜 차이' row 로 줄여. 그 4 row 를 에디터 위에 (또는 loop module 상단 코멘트에) 박아. Portability hack 짤 때마다 그 4 개 중 하나인지 확인. Yes 면 분기 받아들여; No 면 shim 이 너무 새는 거.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.