Fix: LangChain Dependences
This commit is contained in:
@@ -5,10 +5,14 @@ from langchain.chains.combine_documents import create_stuff_documents_chain
|
||||
|
||||
|
||||
def create_rag_chain(llm, retriever):
|
||||
contextualize_q_system_prompt = """Given a chat history and the latest user question \
|
||||
which might reference context in the chat history, formulate a standalone question \
|
||||
which can be understood without the chat history. Do NOT answer the question, \
|
||||
just reformulate it if needed and otherwise return it as is."""
|
||||
contextualize_q_system_prompt = """
|
||||
Given a chat history and the latest user question \
|
||||
which might reference context in the chat history,
|
||||
formulate a standalone question \
|
||||
which can be understood without the chat history.
|
||||
Do NOT answer the question, \
|
||||
just reformulate it if needed and otherwise return it as is.
|
||||
"""
|
||||
contextualize_q_prompt = ChatPromptTemplate.from_messages(
|
||||
[
|
||||
("system", contextualize_q_system_prompt),
|
||||
@@ -21,12 +25,13 @@ def create_rag_chain(llm, retriever):
|
||||
)
|
||||
|
||||
# ___________________Chain con el chat history_______________________-
|
||||
qa_system_prompt = """You are an assistant for question-answering tasks. \
|
||||
qa_system_prompt = """
|
||||
You are an assistant for question-answering tasks. \
|
||||
Use the following pieces of retrieved context to answer the question. \
|
||||
If you don't know the answer, just say that you don't know. \
|
||||
The length of the answer should be sufficient to address what is being asked, \
|
||||
The length of the answer should be sufficient to address
|
||||
what is being asked, \
|
||||
meaning don't limit yourself in length.\
|
||||
|
||||
{context}"""
|
||||
qa_prompt = ChatPromptTemplate.from_messages(
|
||||
[
|
||||
@@ -37,4 +42,5 @@ def create_rag_chain(llm, retriever):
|
||||
)
|
||||
question_answer_chain = create_stuff_documents_chain(llm, qa_prompt)
|
||||
|
||||
return create_retrieval_chain(history_aware_retriever, question_answer_chain)
|
||||
return create_retrieval_chain(
|
||||
history_aware_retriever, question_answer_chain)
|
||||
|
||||
@@ -4,7 +4,9 @@ from langchain_chroma import Chroma
|
||||
def create_retriever(embeddings, persist_directory: str):
|
||||
# Cargamos la vectorstore
|
||||
# vectordb = Chroma.from_documents(
|
||||
# persist_directory=st.session_state.persist_directory, # Este es el directorio del la vs del docuemnto del usuario que se encuentra cargado en la session_state.
|
||||
# persist_directory=st.session_state.persist_directory,
|
||||
# Este es el directorio del la vs del docuemnto del usuario
|
||||
# que se encuentra cargado en la session_state.
|
||||
# embedding_function=embeddings,
|
||||
# )
|
||||
vectordb = Chroma(
|
||||
|
||||
@@ -13,3 +13,5 @@ def create_verctorstore(docs_split: list, embeddings, file_name: str):
|
||||
documents=docs_split,
|
||||
embedding=embeddings,
|
||||
)
|
||||
|
||||
return vectordb
|
||||
|
||||
Reference in New Issue
Block a user