Open gingters opened 7 months ago
Hi @gingters! I'm sorry to hear that you're having so much trouble getting this to work.
Unfortunately, streaming is not yet supported in the RunnableRails
(https://github.com/NVIDIA/NeMo-Guardrails/blob/develop/docs/user_guides/langchain/runnable-rails.md#limitations).
For the second issue, can you check here: https://github.com/NVIDIA/NeMo-Guardrails/blob/develop/nemoguardrails/integrations/langchain/runnable_rails.py#L110 how the input is transformed? This will tell you exactly what will be forwarded to the guardrails.
If you can provide a fully functional config, I can try to reproduce myself.
And last, but not least, make sure the API key you included in the snippet is invalidate.
Hi,
I have massive problems integrating Guardrails in our Langchain-based Chatbot solution. I spent three full working days on something I deemed simple, but utterly failed. I might hold it the wrong way, but I need some clarification on ways to integrate Guardrails into the project.
The project is a Q&A Chatbot, build with Langchain and served with Langserve with streaming support. The chatbot implements filtered RAG, as well as message history and answer-voting.
The main issues are the following:
Especially point 2 is an absolute dealbreaker: The chatbot should provide information to internal support staff and the knowledgebase is the internal tech support database and articles about an software solution.
We have a test question "How do I recognize missing metas?" Metas, in our case, is domain specific jargon for metadata, and this refers to metadata that used in the customer-specific software configuration. With that question, the vector search finds a document regarding a configuration validation system and the answer that is generated usually points the user to that functionality and explains how to validate the meta configuration.
When I added NeMo Guardrails, for whatever reason guardrails writes this output before going to the LLM:
After that, the LLM goes on and provides a general answer regarding SEO metadata on a website, which has absolutely nothing to do with the problem domain at hand and also not with any documents found by our retriever.
This completely breaks the purpose of the Q&A Chatbot for our support staff. In conjunction with my previous issue #472 I also cannot see any details of the LLM call (did Guardrails for whatever reason change the prompt and input to the LLM? if yes, why and how?) in our Langfuse tracing, which makes tracking down the problem impossible for me.
I am looking for guidance and direction to understand what is actually happening, why this is happening and how I can implement a simple "Check for a malicious prompt, if yes answer with a German version of 'Sorry, can't do that', and if no, just continue the chain exactly as it was before", with streaming support.
Our Langchain chain looks like this:
The guardrails is build like this:
As you can see, the chain is composed of separate
RunnablePassthrough.assign()
calls, which are there to keep all parts on the actual value dictionary, because we do need i.e. the found documents later on to display the source url's on the frontend. We also store the question, the generated answer as well as the documents that were retrieved in a database to vote on, so that we can later evaluate what answers were good or bad, and why.We also filter the streaming events that are passed through to the frontend to only the "answer" part, because otherwise the frontend would also get the RAG events and we don't want that.
The config for Guardrails is this: config.yaml