Skip to content

How to use RunnableWithMessageHistory in a RAG pipeline #16582

Answered by eyurtsev
ChristianEvc asked this question in Q&A
Discussion options

You must be logged in to vote

@ChristianEvc Here's a reference imlpementation.

This code is broken down into steps to make it easier to invoke each step to see the inputs / outputs.

You can always debug by sprinkling through the LCEL pipeline.

def print_me(inputs):
   print(inputs)
  return inputs

The code contains an in memory implementation of chat history to make it easier to run the code without any complex set up and understand what's happening under the hood.

from operator import itemgetter
from typing import List

from langchain_openai.chat_models import ChatOpenAI

from langchain_core.chat_history import BaseChatMessageHistory
from langchain_core.documents import Document
from langchain_core.messages import Ba…

Replies: 8 comments 12 replies

Comment options

You must be logged in to vote
1 reply
@ChristianEvc
Comment options

Comment options

You must be logged in to vote
11 replies
@minji-o-j
Comment options

@harris
Comment options

@harris
Comment options

@Arslan-Mehmood1
Comment options

@weissenbacherpwc
Comment options

Answer selected by eyurtsev
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet