NeMo-Guardrails
NeMo-Guardrails copied to clipboard
Problem in Integrating Langchain RunnableWithMessageHistory
I am currently exploring the ways to integrate nemoguardrails to my existing RAG chatbot system.
Guardrail Script
config = RailsConfig.from_content(
yaml_content=YAML_CONTENT, colang_content=COLANG_CONTENT)
guardrails = RunnableRails(config, llm=llm_instance)
RAG chain with message history
conversational_rag_chain = RunnableWithMessageHistory(
rag_chain,
lambda session_id: chat_history,
input_messages_key="input",
history_messages_key="chat_history",
output_messages_key="answer",
)
rag_with_guardrails = guardrails | conversational_rag_chain
When i try to invoke this chain by following line of code
rag_with_guardrails .invoke( {"input": user_query}, config={"configurable": {"session_id": self.session_id}} )
It raises this error when i ask question which needs retrieval
ValueError: Missing keys ['session_id'] in config['configurable'] Expected keys are ['session_id'].When using via .invoke() or .stream(), pass in a config; e.g., chain.invoke({'input': 'foo'}, {'configurable': {'session_id': '[your-value-here]'}})
Bot: {'output': None}
for normal greeting query i got response like below:
{'output': 'Hello there!'}
So, how can i overcome the error and integrate RunnableWithMessageHistory and nemoguardrails together? am i missing something??