RunnablePassthrough

2026. 2. 23. 21:14·AI/LangGraph
반응형

 

 


⭐ 역할

 

 

🧩 역할

  • 데이터를 변환하거나 수정할 필요가 없는 경우
  • 파이프라인의 특정 단계를 건너뛰어야 하는 경우
  • 디버깅 또는 테스트 목적으로 데이터 흐름을 모니터링해야 하는 경우

 

🤖 예제로 흐름 파악하기

  • tax_deduction_question가 invoke를 통해, tax_deduction_chain의 question: RunnablePassthrough로 들어감
  • 마찬가지로 tax_base_equation_question이 tax_base_retrieval_chain의 question: RunnablePassthrough로 들어감
  • tax_base_equation_chain의 tax_base_equation_information에는 tax_base_retrieval_chain이 들어옴
tax_base_retrieval_chain = (
    {'context': retriever, 'question': RunnablePassthrough()} 
    | rag_prompt 
    | llm 
    | StrOutputParser()
)

tax_base_equation_prompt = ChatPromptTemplate.from_messages([
    ('system', '사용자의 질문에서 과세표준을 계산하는 방법을 수식으로 나타내주세요. 부연설명 없이 수식만 리턴해주세요'),
    ('human', '{tax_base_equation_information}')
])

tax_base_equation_chain = (
    {'tax_base_equation_information': RunnablePassthrough()}
    | tax_base_equation_prompt
    | llm
    | StrOutputParser()
)

tax_base_chain = {'tax_base_equation_information' : tax_base_retrieval_chain} | tax_base_equation_chain

def get_tax_base_equation(state: AgentState) -> AgentState:
    tax_base_equation_question = '주택에 대한 종합부동산세 계산시 과세표준을 계산하는 방법을 수식으로 표현해서 알려주세요'
    tax_base_equation = tax_base_chain.invoke(tax_base_equation_question)

    return {'tax_base_equation': tax_base_equation}
    
    tax_deduction_chain = (
    {'context': retriever, 'question': RunnablePassthrough()} 
    | rag_prompt 
    | llm 
    | StrOutputParser()
)

def get_tax_deduction(state: AgentState) -> AgentState:
    # 공제금액을 묻는 질문을 정의합니다.
    tax_deduction_question = '주택에 대한 종합부동산세 계산시 공제금액을 알려주세요'
    
    # tax_deduction_chain을 사용하여 질문을 실행하고 결과를 얻습니다.
    tax_deduction = tax_deduction_chain.invoke(tax_deduction_question)
    
    # state에서 'tax_deduction' 키에 대한 값을 반환합니다.
    return {'tax_deduction': tax_deduction}

 


출처

https://wikidocs.net/235580

 

01. RunnablePassthrough

.custom { background-color: #008d8d; color: white; padding: 0.25em 0.5…

wikidocs.net

 

반응형

'AI > LangGraph' 카테고리의 다른 글

tool  (0) 2026.02.24
지금까지 우리가 만든건 Agent가 아니다??  (0) 2026.02.23
SubGraph와 Router  (0) 2026.02.22
Corrective RAG  (0) 2026.02.22
Self RAG  (0) 2026.02.22
'AI/LangGraph' 카테고리의 다른 글
  • tool
  • 지금까지 우리가 만든건 Agent가 아니다??
  • SubGraph와 Router
  • Corrective RAG
Hamp
Hamp
남들에게 보여주기 부끄러운 잡다한 글을 적어 나가는 자칭 기술 블로그입니다.
  • Hamp
    Hamp의 분리수거함
    Hamp
  • 전체
    오늘
    어제
    • 분류 전체보기 (339)
      • CS (30)
        • 객체지향 (2)
        • Network (7)
        • OS (6)
        • 자료구조 (1)
        • LiveStreaming (3)
        • 이미지 (1)
        • 잡다한 질문 정리 (0)
        • Hardware (2)
        • 이론 (6)
        • 컴퓨터 그래픽스 (0)
      • Firebase (3)
      • Programing Langauge (41)
        • swift (34)
        • python (6)
        • Kotlin (1)
      • iOS (134)
        • UIKit (37)
        • Combine (1)
        • SwiftUI (34)
        • Framework (7)
        • Swift Concurrency (22)
        • Tuist (6)
        • Setting (11)
        • Modularization (1)
        • Instruments (6)
      • PS (59)
        • 프로그래머스 (24)
        • 백준 (13)
        • LeetCode (19)
        • 알고리즘 (3)
      • Git (18)
        • 명령어 (4)
        • 이론 (2)
        • hooks (1)
        • config (2)
        • action (7)
      • Shell Script (2)
      • Linux (6)
        • 명령어 (5)
      • Spring (21)
        • 어노테이션 (6)
        • 튜토리얼 (14)
      • CI-CD (4)
      • Android (0)
        • Jetpack Compose (0)
      • AI (21)
        • 이론 (10)
        • MCP (1)
        • LangGraph (10)
  • 블로그 메뉴

    • 홈
    • 태그
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    투포인터
    Tuist
    백준
    dfs
    lifecycle
    protocol
    IOS
    dp
    GIT
    AVFoundation
    UIKit
    Swift
    프로그래머스
    property
    dispatch
    CS
    concurrency
    SwiftUI
    Spring
    boostcamp
  • 최근 댓글

  • 최근 글

  • 반응형
  • hELLO· Designed By정상우.v4.10.0
Hamp
RunnablePassthrough
상단으로

티스토리툴바