How can i change the original template of ConversationalRetrievalChain ? #3975
Unanswered
tarek-kerbedj
asked this question in
Q&A
Replies: 1 comment
-
I'm assuming you mean you want to change the default prompt for the from langchain.chains import ConversationalRetrievalChain
from langchain.chat_models import ChatOpenAI
from langchain.memory import ConversationBufferMemory
from langchain.prompts import (
ChatPromptTemplate,
HumanMessagePromptTemplate,
SystemMessagePromptTemplate,
)
system_message_prompt = SystemMessagePromptTemplate.from_template(
"Answer the user question based on the context:\n{context}"
)
human_message_prompt = HumanMessagePromptTemplate.from_template(
"{question}"
)
chain = ConversationalRetrievalChain.from_llm(
llm=ChatOpenAI(temperature=0),
retriever=vectorstore.as_retriever(),
memory=ConversationBufferMemory(
memory_key="chat_history",
return_messages=True,
),
combine_docs_chain_kwargs={
"prompt": ChatPromptTemplate.from_messages([
system_message_prompt,
human_message_prompt,
]),
},
) I believe you need to make sure your custom prompt includes the Hope that helps! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello everyone, I have implemented a ConversationalRetrievalChain that deals with stored documents and I did receive good initial results, but I want to change the original template and I couldn't find any guide on how to do it
Beta Was this translation helpful? Give feedback.
All reactions