ArturG9 commited on
Commit
b1fa38c
1 Parent(s): ec375fc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -16
app.py CHANGED
@@ -18,8 +18,7 @@ from langchain_community.document_loaders.directory import DirectoryLoader
18
  from HTML_templates import css, bot_template, user_template
19
  from langchain_core.output_parsers import StrOutputParser
20
  from langchain_core.runnables import RunnablePassthrough
21
- from langchain.retrievers.self_query.base import SelfQueryRetriever
22
- from langchain.chains.query_constructor.base import AttributeInfo
23
 
24
 
25
  lang_api_key = os.getenv("lang_api_key")
@@ -88,21 +87,9 @@ def create_retriever_from_chroma(vectorstore_path="docs/chroma/", search_type='m
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
- contextualize_q_prompt = ChatPromptTemplate.from_messages(
98
- [
99
- ("system", contextualize_q_system_prompt),
100
- MessagesPlaceholder("chat_history"),
101
- ("human", "{input}"),
102
- ]
103
- )
104
 
105
- ha_retriever = create_history_aware_retriever(llm, retriever, contextualize_q_prompt)
106
 
107
  return ha_retriever
108
 
 
18
  from HTML_templates import css, bot_template, user_template
19
  from langchain_core.output_parsers import StrOutputParser
20
  from langchain_core.runnables import RunnablePassthrough
21
+ from langchain import hub
 
22
 
23
 
24
  lang_api_key = os.getenv("lang_api_key")
 
87
 
88
  retriever=vectorstore.as_retriever(search_type='mmr', search_kwargs={"k": 7})
89
 
90
+ rephrase_prompt = hub.pull("langchain-ai/chat-langchain-rephrase")
 
 
 
 
 
 
 
 
 
 
 
 
91
 
92
+ ha_retriever = create_history_aware_retriever(llm, retriever, rephrase_prompt)
93
 
94
  return ha_retriever
95