Open DixitAdh opened 2 months ago
Hi @DixitAdh, have you tried passing the retrieved results as a message with context
role?
Like
{
"role": "context",
"content": {
"relevant_chunks": " HERE GOES THE RETRIEVED CHUNK"
}
}
@Pouyanpi do you have any example which i can follow, i can tell more that i am not executing rag within the nemo, nemo rails sit in front of the chain. so I am not sure where should i add this message with context role. This is how i generate the runnablerails instance
from nemoguardrails import RailsConfig
from nemoguardrails.integrations.langchain.runnable_rails import RunnableRails
def create_runnable_rails(nemo_config_path: str, blocked_term_path: str):
"""
A function to create a nemo guardrail instance
"""
if not nemo_config_path:
raise ValueError("Nemo config path missing")
if not blocked_term_path:
raise ValueError("Blocked terms file path missing")
config = RailsConfig.from_path(nemo_config_path)
custom_data = dict(blocked_terms_path=blocked_term_path)
config.custom_data = custom_data
guardrails = RunnableRails(config)
return guardrails
@DixitAdh
Thanks for the clarification.
Your approach seems right. And the "I'm not sure what to say" message shows that actually the bot message is empty. Because by default when the output rails is triggered the bot refuse to respond flow
gets activated and you will see "I'm sorry, I can't respond to that." Unless you have modified that flow to "I'm not sure what to say"
Try to run the query against the chain in verbose mode:
guardrails = RunnableRails(config, verbose=True)
Then you can better understand what is going on Specially look for Event BotMessage
and Event BotIntent
logs.
Relevant documentation for ref.
Hello @Pouyanpi @drazvan
We have built a RAG chain using langchain and nemo guardrails are wrapping this chain something like
chain_with_rails = guardrails | chain
prompt.ymlWhen the response from the chain is generated, the self check output always returns. "I am not sure what to say"
My question is how should i pass the output from chain to nemo rails to asses that output generated by chain is complying with the prompt that is mentioned.