-
Notifications
You must be signed in to change notification settings - Fork 15.9k
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
DOC: Passing Context to Conversational Chain #7936
Comments
Answer generated by a 🤖 AnswerI understand that you're seeking more detailed documentation on how to pass context (LangChain documents) to the ConversationalRetrievalChain in LangChain. You're also interested in separating the retriever functionality. Let me explain how you can achieve this. In LangChain, the ConversationalRetrievalChain class is designed to manage conversations based on retrieved documents. It takes a chat history and a new question as inputs, and generates an answer. This process involves creating a standalone question from the chat history and the new question, retrieving relevant documents based on this standalone question, and then passing these documents to a language model to generate a final response. To pass context to the ConversationalRetrievalChain, you can use the Here's an example of how you can do this: from langchain.chains import (
StuffDocumentsChain, LLMChain, ConversationalRetrievalChain
)
from langchain.prompts import PromptTemplate
from langchain.llms import OpenAI
combine_docs_chain = StuffDocumentsChain(...)
vectorstore = ...
retriever = vectorstore.as_retriever()
template = (
"Combine the chat history and follow up question into "
"a standalone question. Chat History: {chat_history}"
"Follow up question: {question}"
)
prompt = PromptTemplate.from_template(template)
llm = OpenAI()
question_generator_chain = LLMChain(llm=llm, prompt=prompt)
chain = ConversationalRetrievalChain(
combine_docs_chain=combine_docs_chain,
retriever=retriever,
question_generator=question_generator_chain,
) In this example, the Please note that this is one potential way to pass context to the ConversationalRetrievalChain and separate the retriever functionality. There might be other ways to achieve this depending on your specific use case. If you find this solution helpful and believe it's not covered by the existing documentation, I encourage you to make a pull request to update the documentation. This will be beneficial for other users who might encounter the same issue. SourcesThis response is meant to be useful, save you time, and share context. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. |
From the docs, I understand it's the opposite than what is being explained above in the text (code is correct though):
So the Regarding the original question, it is indeed not always clear what's happening in the background. You can still find some details about the chain(s) yourself by passing |
Hi, @rambabusure! I'm Dosu, and I'm helping the LangChain team manage our backlog. I wanted to let you know that we are marking this issue as stale. From what I understand, you were requesting more documentation on passing context to the conversational chain in order to separate the retriever functionality. I provided a detailed explanation on how to pass context using the Before we close this issue, we wanted to check if it is still relevant to the latest version of the LangChain repository. If it is, please let us know by commenting on the issue. Otherwise, feel free to close the issue yourself or it will be automatically closed in 7 days. Thank you for your contribution to the LangChain repository! |
Hi all, to me, this is still unclear. Mostly, because the example provided by @dosubot and the docstrings seems to be misleading about to things:
I feel like the docstrings should provide a plug-and-play example. That would be great! |
Issue with current documentation:
We don't have enough documentation Conversational chain and found only documentation relates conversational retrieval chain. We are looking for separating the retriever functionality. Please provide some examples on passing context (lang chain documents ) to conversational chain
Idea or request for content:
No response
The text was updated successfully, but these errors were encountered: