Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Integrating NeMo Guardrails with LangChain and LangServe for Chatbot #706

Open
AnkurVera464221 opened this issue Jul 10, 2024 · 0 comments

Comments

@AnkurVera464221
Copy link

Hello, I am currently working on a Retrieval-Augmented Generation (RAG) chatbot using LangChain and LangServe. I am attempting to integrate NeMo Guardrails into this system but am encountering issues with the chat history format when deploying my chain using LangServe.

Here is the detailed setup and issue:

### Setup

  1. LangChain Chain:

I created a LangChain chain which works perfectly in the Python environment.
I deployed it using LangServe, and the input JSON body for input looks like this:
image

  1. NeMo Guardrails Integration:

Integrated NeMo Guardrails with the conversational_retireval_chain using the following code:

chain_with_guardrails = RunnableRails(config, runnable=conversation_chain, input_key="question", output_key="answer") return chain_with_guardrails

This worked well in the Python environment, with the following example running successfully:
chain_with_guardrails.invoke({ "question": "user question", "chat_history": [("Hi", "Hello!"), ("Whats...", "Anwer...)] })

### Issue
When deploying this with LangServe, I encountered the following issues:

{ "input": { "question": "What is its latest release??", "chat_history": [ ["Hi, I am Ankur", "Hello"], ["What is AMP Impact?", "AMP impact?"] ] }, "config": {}, "kwargs": {} }

Error Recieved:

Error while execution generate_bot_message: Unsupported chat history format: <class 'list'>. Full chat history: [['Hi, I am Ankur', 'Hello'], ['What is AMP Impact?', 'AMP impact?']]

Attempt to Change Chat History to Tuples:

Changing each pair in the chat history to tuples, which worked in the Python environment, resulted in JSON parsing issues as JSON does not support tuples.

Input JSON Body:

{ "input": { "question": "What is its latest release??", "chat_history": [ ("Hi, I am Ankur", "Hello"), ("What is AMP Impact?", "AMP impact?") ] }, "config": {}, "kwargs": {} }

Error Received:

{ "detail": [ "Invalid JSON body" ] }

Empty Chat History:

Note: The chain works perfectly when the chat history is empty.

Request
I would like to request guidance on how to properly format the chat history for compatibility with NeMo Guardrails when deploying using LangServe. If there is a specific format or a workaround that I am missing, please let me know. Additionally, if this is an issue with NeMo Guardrails, I would appreciate any fixes or updates.

Thank you for your assistance.

Best regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant