본문 바로가기
C.W.K.
Stream
Lesson 01 of 07 · published

Adapter Pattern — wire 에 두고, prompt 에는 두지 마

~22 min · adapter, production

Level 0Tokenizer
0 XP0/54 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

provider 차이는 wire 경계에 가둬. streaming 형식, tool result를 보내는 방법, 인증 방식은 provider마다 다를 수 있어. 하지만 prompt와 tool 정의까지 provider별로 갈라진다면 adapter 경계가 차이를 충분히 흡수하지 못한 거야.

provider가 새어 나온 곳을 찾아

코드에서 'provider'가 등장하는 곳을 목록으로 만들고 두 그룹으로 나눠. 인증, request body, streaming 형식 같은 합법적인 wire 차이와 prompt 또는 tool variation처럼 공통화해야 할 차이를 구분해.

cwkPippa의 경계

cwkPippa에서는 backend/adapters/base.py가 model API 차이를 다루는 중심 경계야. route, store, frontend는 공통 Claude shape를 사용하고 Codex, Gemini, Ollama vessel은 backend/variants/에서 specialize해 경계를 넓히지 않아.

prompt를 provider 이름으로 갈라놓지 마

'OpenAI면 X prompt, Claude면 Y prompt'처럼 wire 차이를 prompt에 밀어 넣지 마. 공통 prompt를 유지하고 model별 prompt tuning이 정말 필요하다면 별도의 명시적인 layer에서 다뤄.

Code

Production Adapter ABC sketch·python
# Map tool names to callables for the agent loop
TOOLS_MAP = {
    "get_weather": get_weather,
    "search_news": search_news,
    "query_database": query_database,
}

# Tool schemas for the model
TOOL_SCHEMAS = [
    {"type": "function", "name": name, "description": func.__doc__,
     "parameters": get_schema(func), "strict": True}
    for name, func in TOOLS_MAP.items()
]

External links

Exercise

코드에서 'provider'가 등장하는 지점을 찾아 (a) 합법적인 wire 차이와 (b) 공통화해야 할 prompt/tool variation으로 나눠. 그룹 b 하나를 합칠 계획을 작성해.

Progress

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

댓글 0

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

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