C.W.K.
Stream
Lesson 04 of 07 · published

Cross-Cutting Service 로서의 RAG

~11 min · rag, service

Level 0호기심
0 XP0/65 lessons0/17 achievements
0/100 XP to next level100 XP to go0% complete

한 함수

RAG service 가 한 함수: build_rag_context(query) -> str | None. Claude-Pippa 의 chat route 우선으로 디자인 — 변형 생각 없이. 각 변형 route 가 한 줄 추가: rag_context = await build_rag_context(prompt_text). 함수가 어느 두뇌가 consume 할지 모름.

cross-contamination 없는 cross-cutting

RAG 가 shared 인 건 underlying 작업 (ChromaDB 위 semantic search) 이 두뇌 무관 진짜 같음. service shared; route 들 여전히 독립.

graceful degradation

Ollama 안 돌면, build_rag_contextNone 반환. route 가 retrieved context 없이 진행. hard error 보다 degraded chat.

Code

RAG service — 한 함수, 모든 두뇌가 호출·python
async def build_rag_context(query: str, k: int = 5) -> str | None:
    if not await ollama_alive():
        return None
    embedding = await embed(query)
    hits = await chroma.query(
        collection='vault',
        embedding=embedding,
        n_results=k,
    )
    if not hits:
        return None
    return format_for_system_prompt(hits)

Progress

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

댓글 0

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

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