Update app.py
Browse files
app.py
CHANGED
@@ -84,28 +84,28 @@ def create_retriever_from_chroma(vectorstore_path="docs/chroma/", search_type='m
|
|
84 |
vectorstore = Chroma.from_documents(
|
85 |
documents=split_docs, embedding=embeddings, persist_directory=vectorstore_path
|
86 |
)
|
|
|
|
|
|
|
87 |
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
retriever = SelfQueryRetriever.from_llm(
|
102 |
-
llm,
|
103 |
-
vectorstore,
|
104 |
-
document_content_description,
|
105 |
-
metadata_field_info,
|
106 |
-
verbose=True
|
107 |
)
|
108 |
-
|
|
|
|
|
|
|
109 |
|
110 |
|
111 |
|
|
|
84 |
vectorstore = Chroma.from_documents(
|
85 |
documents=split_docs, embedding=embeddings, persist_directory=vectorstore_path
|
86 |
)
|
87 |
+
|
88 |
+
|
89 |
+
retriever=vectorstore.as_retriever(search_type='mmr', search_kwargs={"k": 7})
|
90 |
|
91 |
+
contextualize_q_system_prompt = """If the question is not clear, given a chat history and the latest user question
|
92 |
+
which maybe reference context, formulate a standalone question,
|
93 |
+
which can be understood without the chat history. Do NOT answer the question,
|
94 |
+
just reformulate it if needed and otherwise return it as is."""
|
95 |
+
|
96 |
+
)
|
97 |
+
|
98 |
+
contextualize_q_prompt = ChatPromptTemplate.from_messages(
|
99 |
+
[
|
100 |
+
("system", contextualize_q_system_prompt),
|
101 |
+
MessagesPlaceholder("chat_history"),
|
102 |
+
("human", "{input}"),
|
103 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
)
|
105 |
+
|
106 |
+
ha_retriever = create_history_aware_retriever(llm, retriever, contextualize_q_prompt)
|
107 |
+
|
108 |
+
return ha_retriever
|
109 |
|
110 |
|
111 |
|